The SplPriorityQueue::isEmpty() function is an inbuilt function in PHP that is used to check whether the queue is empty or not.
Syntax:
bool SplPriorityQueue::isEmpty()
Parameters: This function does not accept any parameter.
Return Value: This function returns a boolean value either true or false depending upon the queue is empty or not.
Example 1:
PHP
<?php
class priorityQueue extends SplPriorityQueue {
}
$obj = new priorityQueue();
var_dump( $obj ->isEmpty());
?>
|
Example 2:
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);
var_dump( $obj ->isEmpty());
?>
|
Reference: https://www.php.net/manual/en/splpriorityqueue.isempty.php
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
22 Apr, 2021
Like Article
Save Article