PHP Ds\Queue capacity() Function
The capacity() Function of Ds\Queue class in PHP is used to check the current capacity of a Queue instance.
Syntax:
int capacity( )
Parameters: This function does not accepts any parameters.
Return Value: This function returns the current capacity of the Queue instance.
Below programs illustrate the above method:
Program 1:
<?php // Declare new Queue $q = new \Ds\Queue(); // Use capacity() function // to check the current capacity var_dump($q->capacity()); ?> |
chevron_right
filter_none
Output:
int(8)
Program 2:
<?php // Declare new Queue $q = new \Ds\Queue(); echo("Current Capacity is: "); // Use capacity() function // to check the current capacity var_dump($q->capacity()); echo("Current Capacity is: "); // Use allocate() function to // allocate capacity $q->allocate(5); // Display the allocated vector // capacity var_dump($q->capacity()); // Use allocate() function to // allocate capacity $q->allocate(120); // Display the allocated vector // capacity var_dump($q->capacity()); ?> |
chevron_right
filter_none
Output:
Current Capacity is: int(8) Current Capacity is: int(8) int(128)
Reference: http://php.net/manual/en/ds-queue.capacity.php
Recommended Posts:
- PHP | Ds\Set capacity() Function
- PHP | Ds\Map capacity() Function
- PHP | Ds\Sequence capacity() Function
- PHP Ds\PriorityQueue capacity() Function
- PHP | Ds\Deque capacity() Function
- PHP | Ds\Vector capacity() Function
- PHP | each() Function
- PHP | Ds\Map last() Function
- PHP | Ds\Map map() Function
- PHP | Ds\Set first() Function
- PHP | key() Function
- PHP | Ds\Set add() Function
- PHP | min( ) Function
- PHP | pos() Function
- PHP | Ds\Set last() Function
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.



