• PHP Video Tutorials

PHP - Ds Deque first() Functions



Ds\Deque::first() function can return the first value in the deque.

Syntax

public mixed Ds\Deque::first( void )

Ds\Deque::first() function doesn't have any parameters. This function can return the first value in the deque.

Ds\Deque::first() function can throw UnderflowException if empty.

Example 1

<?php 
   $deque = new \Ds\Deque([10, 20, 8, 40, 50, 5]); 
   echo("The elements in the deque: \n"); 
   print_r($deque); 
   
   echo("\n The first element in the deque:"); 
   var_dump($deque->first()); 
?>

Example 2

<?php 
   $deque = new \Ds\Deque(["Tutorials", "Point", "Tutorix"]); 
   echo("The elements in the deque: \n"); 
   print_r($deque); 
   
   echo("\n The first element in the deque:");  
   var_dump($deque->first()); 
?>
php_function_reference.htm
Advertisements