Open In App

PHP Ds\PriorityQueue count() Function

Improve
Improve
Like Article
Like
Save
Share
Report

The Ds\PriorityQueue::count() Function in PHP is used to get the count of elements present in a Priority Queue instance.

Syntax

int public Ds\PriorityQueue::count( void )

Parameters: This function does not accepts any parameters.

Return Value: This function calculates the number of elements present in a Priority Queue instance and returns the count.

Below programs illustrate the Ds\PriorityQueue::count() Function in PHP:

Program 1:  

PHP




<?php
 
// Declare new PriorityQueue
$pq = new \Ds\PriorityQueue();
 
// Add elements to the PriorityQueue
$pq->push("One", 1);
$pq->push("Two", 2);
$pq->push("Three", 3);
 
// Count the number of elements
// in this PriorityQueue
print_r($pq->count());
 
?>


Output: 

3 








 

Program 2: 

PHP




<?php
 
// Declare new PriorityQueue
$pq = new \Ds\PriorityQueue();
 
// Add elements to the PriorityQueue
$pq->push("Geeks", 1);
$pq->push("for", 2);
$pq->push("Geeks", 3);
 
// Count the number of elements
// in this PriorityQueue
print_r($pq->count());
 
?>


Output: 

3








 

Reference: http://php.net/manual/en/ds-priorityqueue.count.php
 


Last Updated : 09 Nov, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads