chaokunyang commented on code in PR #2112:
URL: https://github.com/apache/fury/pull/2112#discussion_r2019736165


##########
dart/packages/fury/lib/src/util/extension/list_extension.dart:
##########
@@ -0,0 +1,55 @@
+extension ListExtension on List {
+  E? binarySearch<E>(E target, int Function(E a, E b) compare) {
+    int low = 0;
+    int high = length - 1;
+    while (low <= high) {
+      int mid = (low + high) >> 1;
+      int cmp = compare(this[mid], target);
+      if (cmp == 0) {
+        return this[mid];
+      } else if (cmp < 0) {
+        low = mid + 1;
+      } else {
+        high = mid - 1;
+      }
+    }
+    return null;
+  }
+
+  // void _quickSort<E>(int l, int r,
+  //   int Function(int a, E ele) compare,
+  //   void Function(int index1, int index2) swap,
+  // ){
+  //   if (l >= r) return;
+  //   int i = l - 1;
+  //   int j = r + 1;
+  //   E pivot = this[(l + r) ~/ 2];
+  //   while(i < j){
+  //     do {
+  //       ++i;
+  //     } while(compare(i, pivot) < 0);
+  //     do {
+  //       --j;
+  //     } while(compare(j, pivot) > 0);
+  //     if (i < j) {
+  //       // 交换元素

Review Comment:
   Use english comments, or remove commented code



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to