mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-12-22 18:21:51 +01:00
Change algorithm
This commit is contained in:
parent
ec83d01dca
commit
e164847df4
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user