public function put($element)
    {
        $nodeId   = count($this->_heap);
        $parentId = ($nodeId-1) >> 1;   // floor( ($nodeId-1)/2 )

        while ($nodeId != 0  &&  $this->_less($element, $this->_heap[$parentId])) {
            // Move parent node down
            $this->_heap[$nodeId] = $this->_heap[$parentId];

            // Move pointer to the next level of tree
            $nodeId   = $parentId;
            $parentId = ($nodeId-1) >> 1;   // floor( ($nodeId-1)/2 )
        }

        // Put new node into the tree
        $this->_heap[$nodeId] = $element;
    }
public function put($element)
    {
        $nodeId   = count($this->_heap);
        $parentId = ($nodeId-1) >> 1;   // floor( ($nodeId-1)/2 )

        while ($nodeId != 0  &&  $this->_less($element, $this->_heap[$parentId])) {
            // Move parent node down
            $this->_heap[$nodeId] = $this->_heap[$parentId];

            // Move pointer to the next level of tree
            $nodeId   = $parentId;
            $parentId = ($nodeId-1) >> 1;   // floor( ($nodeId-1)/2 )
        }

        // Put new node into the tree
        $this->_heap[$nodeId] = $element;
    }
public function put ( $ element ) { $ nodeId = count ( $ this -> _heap ) ; $ parentId = ( $ nodeId - 1 ) >> 1 ; // floor( ($nodeId-1)/2 ) while ( $ nodeId != 0 && $ this -> _less ( $ element , $ this -> _heap [ $ parentId ] ) ) { // Move parent node down $ this -> _heap [ $ nodeId ] = $ this -> _heap [ $ parentId ] ; // Move pointer to the next level of tree $ nodeId = $ parentId ; $ parentId = ( $ nodeId - 1 ) >> 1 ; // floor( ($nodeId-1)/2 ) } // Put new node into the tree $ this -> _heap [ $ nodeId ] = $ element ; }
Add element to the queue

O(log(N)) time

@param mixed $element
Add element to the queue