This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::vector<int> NativeSampleModule::sort(jsi::Runtime& rt, std::vector<int> input) { | |
int i = 0; | |
int j = 0; | |
int temp = 0; | |
std::vector<int> foo = input; | |
for(i = 0; i < foo.size(); i++) { | |
for(j = 0; j < foo.size() - 1; j++) { | |
if(foo[j + 1] < foo[j]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)sort:(NSMutableArray *)arr resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject { | |
NSMutableArray <NSNumber *>*foo = [[NSMutableArray alloc] initWithArray:arr copyItems:YES]; | |
for (int i = 0; i < [foo count]; i++) { | |
for (int j = 0; j < [foo count] - 1; j++) { | |
if (foo[j + 1].integerValue < foo[j].integerValue) { | |
NSInteger a = foo[j].integerValue; | |
foo[j] = foo[j + 1]; | |
foo[j + 1] = @(a); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func sort(result: FlutterResult, _ array: [Int]) { | |
var arr = array | |
for _ in 0...arr.count { | |
for value in 1...arr.count - 1 { | |
if arr[value-1] > arr[value] { | |
let largerValue = arr[value-1] | |
arr[value-1] = arr[value] | |
arr[value] = largerValue | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sortCPP = arr => { | |
let mean = 0; | |
for (let i = 0; i < 1000; i++) { | |
const startTime = performance.now(); | |
NativeSampleModule.sort(arr); | |
const endTime = performance.now(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sortObjectiveC = async arr => { | |
let mean = 0; | |
for (let i = 0; i < 1000; i++) { | |
const startTime = performance.now(); | |
await RTNSorter?.sort(arr); | |
const endTime = performance.now(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<void> _sort() async { | |
try { | |
double mean = 0; | |
for (var i = 0; i < 1000; i++) { | |
final stopwatch = Stopwatch()..start(); | |
await platform.invokeMethod('sort', list10); | |
stopwatch.stop(); | |
// Don't worry, I converted it to milliseconds afterwards |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Article { | |
title: string; | |
date: string; | |
} | |
// ... | |
interface ArticleBlockProps extends Article { | |
isCenter: boolean; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const height = Dimensions.get('window').height; | |
const blockSize = 70; | |
function ItemSeparator() { | |
return <View style={{height: 10}} />; | |
} | |
function ListSpacer() { | |
return <View style={{height: height / 2 - blockSize}} />; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setCenteredIndex(Math.round(e.nativeEvent.contentOffset.y / blockSize)); |
OlderNewer