517 |
|
private void fixDown(int k) { |
518 |
|
int j; |
519 |
|
if (comparator == null) { |
520 |
< |
while ((j = k << 1) <= size && j > 0) { |
520 |
> |
while ((j = k << 1) <= size && (j > 0)) { |
521 |
|
if (j<size && ((Comparable<E>)queue[j]).compareTo((E)queue[j+1]) > 0) |
522 |
|
j++; // j indexes smallest kid |
523 |
|
if (((Comparable<E>)queue[k]).compareTo((E)queue[j]) <= 0) |
526 |
|
k = j; |
527 |
|
} |
528 |
|
} else { |
529 |
< |
while ((j = k << 1) <= size && j > 0) { |
529 |
> |
while ((j = k << 1) <= size && (j > 0)) { |
530 |
|
if (j < size && comparator.compare((E)queue[j], (E)queue[j+1]) > 0) |
531 |
|
j++; // j indexes smallest kid |
532 |
|
if (comparator.compare((E)queue[k], (E)queue[j]) <= 0) |