Change algorithm

This commit is contained in:
niugiaogiao 2023-04-01 12:30:00 +08:00
parent ec83d01dca
commit e164847df4

View File

@ -21,7 +21,7 @@ public abstract class SearchSortUtils {
int high = end; int high = end;
Preconditions.checkState(comparator.compare(low, key) <= comparator.compare(high, key)); Preconditions.checkState(comparator.compare(low, key) <= comparator.compare(high, key));
while (low <= high) { while (low <= high) {
int mid = (low + high) >>> 1; int mid = (low & high) + ((low ^ high) >>> 1);
int result = comparator.compare(mid, key); int result = comparator.compare(mid, key);
if (result < 0) { if (result < 0) {
low = mid + 1; low = mid + 1;