public void moveToPrevious() {
if (!isValid()) {
return;
}
final ComparableIntPointerIterator it0 = checkConcurrentModification(0);
if (!this.wentForward) {
it0.dec();
// this also takes care of invalid iterators
heapify_down(it0, -1);
} else {
// We need to decrement everything.
int lvi = this.indexes.length - 1;
int i = 1;
while (i <= lvi) {
// Any iterator other than the current one needs to be
// decremented until it's pointing at something that's
// smaller than the current element.
final ComparableIntPointerIterator it = checkConcurrentModification(i);
// If the iterator we're considering is not valid, we
// set it to the last element. This should be it for this iterator...
if (!it.isValid()) {
it.moveToLast();
}
// Decrement the iterator while it is valid and pointing
// at something greater than the current element.
while (it.isValid() && is_before(it, it0, -1)) {
it.dec();
}
// find placement
if (it.isValid()) {
heapify_up(it, i, -1);
++i;
} else {
// swap this iterator with the last possibly valid one
// lvi might be equal to i, this will not be a problem