void siftDown(Heap h, Node n){ Node min = minChild(h,n); while ((n->location < h->unsolved-1) && (min != NULL) && (n->totalCost > min->totalCost)){ swap(h,n,min); min = minChild(h,n); } }
void D_HEAP<KeyType>::siftDown(int idx) { if ((idx >= sizeTree_) || (idx < 0)) throw myExcp("Out of range."); int c = minChild(idx); while ((c != -1) && (tree_[c] < tree_[idx])) { swap((int)c, idx); idx = (int)c; c = minChild(idx); } }
bool CPriorityHeap<T>::bubbleDown(int i) { int c = minChild(i); while (c < index) { if (heap[i].priority > heap[c].priority) { CPriority<T> temp(heap[c].key, heap[c].priority); heap[c].priority = heap[i].priority; heap[c].key = heap[i].key; heap[i].priority = temp.priority; heap[i].key = temp.key; }else break; i = c; c = minChild(i); } return true; }