static int generalizedBinarySearch2(L l, IF1 cmp) {
ret generalizedBinarySearch2(l, 0, l(l), cmp);
}
static int generalizedBinarySearch2(L l, int fromIndex, int toIndex, IF1 cmp) {
int low = fromIndex;
int high = toIndex - 1;
while (low <= high) {
int mid = (low + high) >>> 1;
A midVal = l.get(mid);
int c = cmp.get(midVal);
if (c < 0)
low = mid + 1;
else if (c > 0)
high = mid - 1;
else
ret mid; // key found
}
ret -(low + 1); // key not found.
}