PHP SplPriorityQueue isEmpty() Function Last Updated : 22 Apr, 2021 Comments Improve Suggest changes Like Article Like Report 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 // Declare empty class class priorityQueue extends SplPriorityQueue { } // Create an object of priority queue $obj = new priorityQueue(); // Use isEmpty() function to check // priority queue is empty or not var_dump($obj->isEmpty()); ?> Outputbool(true) Example 2: PHP <?php // Declare a class class priorityQueue extends SplPriorityQueue { // Compare function to compare priority // queue elements public function compare($p1, $p2) { if ($p1 === $p2) return 0; return $p1 < $p2 ? -1 : 1; } } // Create an object of priority queue $obj = new priorityQueue(); // Insert elements into the queue $obj->insert("Geeks",2); $obj->insert("GFG",1); $obj->insert("G4G",3); $obj->insert('G',4); // Use isEmpty() function to check // priority queue is empty or not var_dump($obj->isEmpty()); ?> Outputbool(false) Reference: https://www.php.net/manual/en/splpriorityqueue.isempty.php Comment More infoAdvertise with us Next Article PHP SplPriorityQueue isEmpty() Function A ashokjaiswal Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP SplPriorityQueue insert() Function The SplPriorityQueue::insert() function is an inbuilt function in PHP which is used to inserts an element in the queue by sifting the elements. Insert elements in priority queue by given priority. Syntax: bool SplPriorityQueue::insert( mixed $value, mixed $priority ) Parameters: This function accept 2 min read PHP SplPriorityQueue key() Function The SplPriorityQueue::key() function is an inbuilt function in PHP that is used to return the current node index. Syntax: mixed SplPriorityQueue::key() Parameters: This function does not accept any parameter. Return Value: This function returns the current node index. Example: PHP <?php // Declar 1 min read PHP SplPriorityQueue next() Function 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 // Decl 1 min read PHP SplPriorityQueue isCorrupted() Function The SplPriorityQueue::isCorrupted() function is an inbuilt function in PHP that is used to tells the priority queue is in a corrupted state or not. Syntax: bool SplPriorityQueue::isCorrupted() Parameters: This function does not accept any parameter. Return Value: This function returns true if the pr 1 min read PHP SplPriorityQueue count() Function The SplPriorityQueue::count() function is an inbuilt function in PHP which is used to count the number of elements in the queue. Syntax: int SplPriorityQueue::count() Parameters: This function does not accept any parameters. Return Value: This function returns the number of elements in the queue. Ex 1 min read PHP SplPriorityQueue current() Function The SplPriorityQueue::current() function is an inbuilt function in PHP which is used to return the current node pointed by the iterator. Syntax: mixed SplPriorityQueue::current() Parameters: This function does not accept any parameter. Return Value: This function returns the value/priority of the cu 1 min read PHP SplPriorityQueue compare() Function The SplPriorityQueue::compare() function is an inbuilt function in PHP which is used to compare the priority queue elements to place at a particular order in the heap data structure. Syntax: int SplPriorityQueue::compare( mixed $priority1 , mixed $priority2 ) Parameters: This function accepts two pa 2 min read PHP SplHeap isEmpty() Function The SplHeap::isEmpty() function is an inbuilt function in PHP which is used to check whether the heap is empty or not. Generally, the Heap Data Structure are of two types: Max-Heap: In a Max-Heap the key present at the root node must be greatest among the keys present at all of its children. The sam 2 min read PHP SplDoublyLinkedList isEmpty() Function The SplDoublyLinkedList::isEmpty() function is an inbuilt function in PHP which is used to check whether the doubly linked list is empty or not. Syntax: bool SplDoublyLinkedList::isEmpty( void ) Parameters: This function does not accepts any parameters. Return Value: This function returns True if do 1 min read PHP | is_writable() Function The is_writable() function in PHP used to check whether the specified file is writable or not. The name of the file is sent as a parameter to the is_writable() function and it returns True if the filename exists and is writable. Name of a directory can also be a parameter to the is_writable() functi 2 min read Like