Merge pull request #140 from mpoindexter/master-fix-collections-binary-search

Fix the order comparison is applied in for binarySearch to match the …
This commit is contained in:
Alexey Andreev 2015-07-21 18:36:20 +03:00
commit b9f43b981f

View File

@ -259,10 +259,10 @@ public class TCollections extends TObject {
while (true) { while (true) {
int i = (l + u) / 2; int i = (l + u) / 2;
T e = list.get(i); T e = list.get(i);
int cmp = c.compare(key, e); int cmp = c.compare(e, key);
if (cmp == 0) { if (cmp == 0) {
return i; return i;
} else if (cmp < 0) { } else if (cmp > 0) {
u = i - 1; u = i - 1;
if (u < l) { if (u < l) {
return -i - 1; return -i - 1;