The SplPriorityQueue::next() function is an inbuilt function in PHP that is used to extract the top node from the queue.
Syntax:
void SplPriorityQueue::next()
Parameters: This function does not accept any parameter.
Return Value: This function does not return any value.
Example:
PHP
<?php
class priorityQueue extends SplPriorityQueue {
public function compare( $p1 , $p2 ) {
if ( $p1 === $p2 ) return 0;
return $p1 < $p2 ? -1 : 1;
}
}
$obj = new priorityQueue();
$obj ->insert( "Geeks" ,2);
$obj ->insert( "GFG" ,1);
$obj ->insert( "G4G" ,3);
$obj ->insert( 'G' ,4);
while ( $obj ->valid()){
echo $obj ->current() . " " ;
$obj ->next();
}
?>
|
Reference: https://www.php.net/manual/en/splpriorityqueue.next.php