in concurrency-loadbalancer-core/src/main/java/com/uber/concurrency/loadbalancer/utils/HashIndexedPriorityQueue.java [184:212]
private void siftDown(int index, E e) {
int oIndex = index;
int size = entityList.size();
int mid = size >>> 1;
while (index < mid) {
int cIndex = (index << 1) + 1;
int rcIndex = cIndex + 1;
E c = entityList.get(cIndex);
if (rcIndex < size) {
E rc = entityList.get(rcIndex);
int cmp = comparator.compare(c, rc);
if (cmp > 0 || (cmp == 0 && booleanGenerator.next())) {
c = rc;
cIndex = rcIndex;
}
}
if (comparator.compare(c, e) > 0) {
break;
}
entityList.set(index, c);
entityToIndex.put(c, index);
index = cIndex;
}
if (oIndex == index)
return;
entityList.set(index, e);
entityToIndex.put(e, index);
}