• PHP Video Tutorials

PHP - Ds\PriorityQueue::peek() Function



Ds\PriorityQueue::peek() function can return a value at the front of a queue.

Syntax

public mixed Ds\PriorityQueue::peek( void )

Ds\PriorityQueue::peek() function can return a value at the front of a queue but do not remove it.

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

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

Example

<?php
   $pqueue = new \Ds\PriorityQueue();  
   $pqueue->push("Tutorials", 1); 
   $pqueue->push("Point", 2); 
   $pqueue->push("India", 3); 
  
   echo "The PriorityQueue is: \n"; 
   print_r($pqueue); 
   
   echo "\n The element at front of queue is:"; 
   print_r($pqueue->peek()); 
?>
php_function_reference.htm
Advertisements