PHP | Ds\Stack capacity() Function
The Ds\Stack::capacity() function is an inbuilt function in PHP which is used to return the current capacity of the stack.
Syntax:
int Ds\Stack::capacity( void )
Parameters: This function does not accept any parameters.
Return Value: This function returns the current capacity of the stack.
Below programs illustrate the Ds\Stack::capacity() function in PHP:
Program 1:
<?php // Declare new Stack $stack = new \Ds\Stack(); // Use capacity() function to check // the current capacity var_dump($stack->capacity()); ?> |
int(8)
Program 2:
<?php // Declare new Stack $stack = new \Ds\Stack(); echo("Current Capacity is: "); // Use capacity() function // to check the current capacity var_dump($stack->capacity()); echo("Current Capacity is: "); // Use allocate() function to // allocate capacity $stack->allocate(5); // Display the allocated vector // capacity var_dump($stack->capacity()); echo("Current Capacity is: "); // Use allocate() function to // allocate capacity $stack->allocate(120); // Display the allocated vector // capacity var_dump($stack->capacity()); ?> |
Current Capacity is: int(8) Current Capacity is: int(8) Current Capacity is: int(120)
Reference: https://www.php.net/manual/en/ds-stack.capacity.php
Recommended Posts:
- PHP | Ds\Set capacity() Function
- PHP | Ds\Map capacity() Function
- PHP | Ds\Vector capacity() Function
- PHP Ds\PriorityQueue capacity() Function
- PHP Ds\Queue capacity() Function
- PHP | Ds\Deque capacity() Function
- PHP | Ds\Sequence capacity() Function
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- How to get the function name inside a function in PHP ?
- D3.js | d3.map.get() Function
- PHP Ds\Set sum() Function
- D3.js | d3.max() function
- p5.js | max() function
- p5.js | hue() 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.



