PHP Ds\PriorityQueue capacity() Function

The capacity() Function of Ds\PriorityQueue class in PHP is used to check the current capacity of a PriorityQueue instance.

Syntax:

int capacity( )

Parameters: This function does not accepts any parameters.

Return Value: This function returns the current capacity of the PriorityQueue instance.

Below programs illustrate the above method:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php 
  
// Declare new PriorityQueue 
$pq = new \Ds\PriorityQueue(); 
  
// Use capacity() function 
// to check the current capacity
var_dump($pq->capacity()); 
  
?> 

chevron_right


Output:

int(8)

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php 
  
// Declare new PriorityQueue 
$pq = new \Ds\PriorityQueue(); 
  
echo("Current Capacity is: "); 
  
// Use capacity() function 
// to check the current capacity
var_dump($pq->capacity()); 
  
echo("Current Capacity is: "); 
  
// Use allocate() function to 
// allocate capacity 
$pq->allocate(5); 
  
// Display the allocated vector 
// capacity 
var_dump($pq->capacity()); 
  
// Use allocate() function to 
// allocate capacity 
$pq->allocate(120); 
  
// Display the allocated vector 
// capacity 
var_dump($pq->capacity()); 
  
?> 

chevron_right


Output:

Current Capacity is: int(8)
Current Capacity is: int(8)
int(128)

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



My Personal Notes arrow_drop_up

The function of education is to teach one to think intensively and to think critically

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.