Chromium Code Reviews| Index: lib/src/algorithms.dart |
| diff --git a/lib/src/algorithms.dart b/lib/src/algorithms.dart |
| index 2b66d7df7014cfe921afa2592d5b447e0dc6ed2a..47f0789ebfe2117a59be40801aaa1ec20ee16118 100644 |
| --- a/lib/src/algorithms.dart |
| +++ b/lib/src/algorithms.dart |
| @@ -5,7 +5,8 @@ |
| import "dart:math" as math; |
| /// Version of [binarySearch] optimized for comparable keys |
| -int _comparableBinarySearch(List<Comparable> list, Comparable value) { |
| +int _comparableBinarySearch/*<T extends Comparable<T>>*/( |
| + List<Comparable/*<T>*/> list, Comparable/*<T>*/ value) { |
| int min = 0; |
| int max = list.length; |
| while (min < max) { |
| @@ -31,9 +32,10 @@ int _comparableBinarySearch(List<Comparable> list, Comparable value) { |
| /// the objects. |
| /// |
| /// Returns -1 if [value] is not in the list by default. |
| -int binarySearch(List sortedList, value, { int compare(a, b) }) { |
| +int binarySearch/*<T extends Comparable<T>>*/( |
| + List/*<T>*/ sortedList, /*=T*/ value, { int compare(/*=T*/ a, /*=T*/ b) }) { |
| if (compare == null) { |
| - return _comparableBinarySearch(sortedList, value); |
| + return _comparableBinarySearch/*<T>*/(sortedList, value); |
|
Leaf
2016/03/18 16:35:40
Does inference not figure out this type argument?
ochafik
2016/03/19 01:38:33
It does, thanks!
|
| } |
| int min = 0; |
| int max = sortedList.length; |
| @@ -79,7 +81,8 @@ int _comparableLowerBound(List<Comparable> list, Comparable value) { |
| /// |
| /// Returns [sortedList.length] if all the items in [sortedList] compare less |
| /// than [value]. |
| -int lowerBound(List sortedList, value, { int compare(a, b) }) { |
| +int lowerBound/*<T extends Comparable<T>>*/( |
| + List/*<T>*/ sortedList, /*=T*/ value, { int compare(/*=T*/ a, /*=T*/ b) }) { |
| if (compare == null) { |
| return _comparableLowerBound(sortedList, value); |
| } |