• PHP Video Tutorials

PHP - Ds\PriorityQueue::pop() Function



Ds\PriorityQueue::pop() function can remove and return a value with highest priority.

Syntax

public mixed Ds\PriorityQueue::pop( void )

Ds\PriorityQueue::pop() function can remove and return a value at the front of the queue, which means the value with the highest priority.

Ds\PriorityQueue::pop() function doesn't have any parameters.

Ds\PriorityQueue::pop() function can return a removed value, which was at the front of the queue.

Ds\PriorityQueue::pop() function can throw UnderflowException if empty.

Example

<?php  
   $pqueue = new \Ds\PriorityQueue();  
   $pqueue->push("Tutorials", 1); 
   $pqueue->push("Point", 3); 
   $pqueue->push("India", 2); 
  
   echo "The initial PriorityQueue is: \n"; 
   print_r($pqueue); 
  
   echo "\n The popped element is:"; 
   print_r($pqueue->pop()); 
  
   echo "\n The final PriorityQueue is: \n";
   print_r($pqueue); 
?>
php_function_reference.htm
Advertisements