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