src/PriorityQueue.php
public function pop()
    {
        if ($this->isEmpty()) {
            throw new UnderflowException();
        }

        // Last leaf of the heap to become the new root.
        $leaf = array_pop($this->heap);

        if (empty($this->heap)) {
            return $leaf->value;
        }

        // Cache the current root value to return before replacing with next.
        $value = $this->getRoot()->value;

        // Replace the root, then sift down.
        $this->setRoot($leaf);
        $this->checkCapacity();

        return $value;
    }
public function pop()
    {
        if ($this->isEmpty()) {
            throw new UnderflowException();
        }

        // Last leaf of the heap to become the new root.
        $leaf = array_pop($this->heap);

        if (empty($this->heap)) {
            return $leaf->value;
        }

        // Cache the current root value to return before replacing with next.
        $value = $this->getRoot()->value;

        // Replace the root, then sift down.
        $this->setRoot($leaf);
        $this->checkCapacity();

        return $value;
    }
public function pop ( ) { if ( $ this -> isEmpty ( ) ) { throw new UnderflowException ( ) ; } // Last leaf of the heap to become the new root. $ leaf = array_pop ( $ this -> heap ) ; if ( empty ( $ this -> heap ) ) { return $ leaf -> value ; } // Cache the current root value to return before replacing with next. $ value = $ this -> getRoot ( ) -> value ; // Replace the root, then sift down. $ this -> setRoot ( $ leaf ) ; $ this -> checkCapacity ( ) ; return $ value ; }
Returns and removes the value with the highest priority in the queue.

@return mixed
Returns and removes the value with the highest priority in the queue .