src/PriorityQueue.php
private function siftDown(int $node)
    {
        $last = floor(count($this->heap) / 2);

        for ($parent = $node; $parent < $last; $parent = $leaf) {

            // Determine the largest leaf to potentially swap with the parent.
            $leaf = $this->getLargestLeaf($parent);

            // Done if the parent is not greater than its largest leaf
            if ($this->compare($parent, $leaf) > 0) {
                break;
            }

            $this->swap($parent, $leaf);
        }
    }
private function siftDown(int $node)
    {
        $last = floor(count($this->heap) / 2);

        for ($parent = $node; $parent < $last; $parent = $leaf) {

            // Determine the largest leaf to potentially swap with the parent.
            $leaf = $this->getLargestLeaf($parent);

            // Done if the parent is not greater than its largest leaf
            if ($this->compare($parent, $leaf) > 0) {
                break;
            }

            $this->swap($parent, $leaf);
        }
    }
private function siftDown ( int $ node ) { $ last = floor ( count ( $ this -> heap ) / 2 ) ; for ( $ parent = $ node ; $ parent < $ last ; $ parent = $ leaf ) { // Determine the largest leaf to potentially swap with the parent. $ leaf = $ this -> getLargestLeaf ( $ parent ) ; // Done if the parent is not greater than its largest leaf if ( $ this -> compare ( $ parent , $ leaf ) > 0 ) { break ; } $ this -> swap ( $ parent , $ leaf ) ; } }
Starts the process of sifting down a given node index to ensure that
the heap's properties are preserved.

@param int $node
Starts the process of sifting down a given node index to ensure that the heap s properties are preserved .