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:
public Ds\Vector::capacity( void ) : int
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\Queue capacity() Function
- PHP Ds\PriorityQueue capacity() Function
- PHP | Ds\Deque capacity() Function
- PHP | Ds\Sequence capacity() Function
- How to get the function name from within that function using JavaScript ?
- p5.js | min() function
- p5.js | nf() Function
- D3.js | d3.min() function
- D3.js | d3.sum() function
- PHP | pos() Function
- D3.js | d3.mean() function
- PHP | key() Function
- PHP | sin( ) 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.



