void heap<T, Compare>::heapifyDown( size_t currentIdx ) { /// @todo Implement the heapifyDown algorithm. if(!hasAChild(currentIdx)) return; size_t pirorChildIdx =maxPriorityChild(currentIdx ); if( !higherPriority( _elems[ currentIdx ], _elems[ pirorChildIdx ] ) ) { std::swap( _elems[ currentIdx ], _elems[ pirorChildIdx ] ); heapifyDown(pirorChildIdx); } }
void heap<T, Compare>::heapifyDown( size_t currentIdx ) { /// @todo Implement the heapifyDown algorithm. if(hasAChild(currentIdx)) { size_t minChildIndex=maxPriorityChild(currentIdx); if(!higherPriority(_elems[currentIdx],_elems[minChildIndex])) { std::swap(_elems[currentIdx],_elems[minChildIndex]); heapifyDown(minChildIndex); } } }