indexOf on sorted lists should return the first match
This commit is contained in:
@@ -616,7 +616,10 @@ public final class IntList implements Serializable, Cloneable {
|
||||
|
||||
int result = -1;
|
||||
if (sorted) {
|
||||
final int insertionPoint = Arrays.binarySearch(data, offset, size(), value);
|
||||
int insertionPoint = Arrays.binarySearch(data, offset, size(), value);
|
||||
while (insertionPoint > 0 && insertionPoint > offset && data[insertionPoint - 1] == value) {
|
||||
insertionPoint--;
|
||||
}
|
||||
result = insertionPoint < 0 ? -1 : insertionPoint;
|
||||
} else {
|
||||
for (int i = offset; i < size; i++) {
|
||||
@@ -867,5 +870,4 @@ public final class IntList implements Serializable, Cloneable {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user