PHP | Ds\Vector capacity() Function
The Ds\Vector::capacity() function is an inbuilt function in PHP which is used to return the current capacity of the vector.
Syntax:
int public Ds\Vector::capacity( void )
Parameters: This function does not accept any parameter.
Return Value: This function returns the current capacity of vector.
Below programs illustrate the Ds\Vector::capacity() function in PHP:
Program 1:
<?php // Declare a vector $vector = new \Ds\Vector(); // Use capacity() function to // find the vector capacity // and display it var_dump($vector->capacity()); // Use push() function to add // vector element $vector->push(...range(1, 20)); // Display the vector capacity var_dump($vector->capacity()); ?> |
Output:
int(8) int(20)
Program 2:
<?php // Declare a vector $vector = new \Ds\Vector(); // Use capacity() function to // find the vector capacity // and display it var_dump($vector->capacity()); // Use push() function to add // vector element $vector->push(...range(1, 100)); // Display the vector capacity var_dump($vector->capacity()); ?> |
Output:
int(8) int(100)
Reference: http://php.net/manual/en/ds-vector.capacity.php
Recommended Posts:
- PHP | Ds\Map capacity() Function
- PHP | Ds\Set capacity() Function
- PHP | Ds\Sequence capacity() Function
- PHP Ds\Queue capacity() Function
- PHP | Ds\Deque capacity() Function
- PHP Ds\PriorityQueue capacity() Function
- PHP | Ds\Stack capacity() Function
- How to call a function that return another function in JavaScript ?
- How to get the function name inside a function in PHP ?
- How to get the function name from within that function using JavaScript ?
- PHP | pos() Function
- PHP | abs() Function
- PHP | Ds\Map map() Function
- PHP | Ds\Map last() Function
- p5.js | box() 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.



