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
$vector = new \Ds\Vector();
var_dump( $vector ->capacity());
$vector ->push(...range(1, 20));
var_dump( $vector ->capacity());
?>
|
Output:
int(8)
int(20)
Program 2:
<?php
$vector = new \Ds\Vector();
var_dump( $vector ->capacity());
$vector ->push(...range(1, 100));
var_dump( $vector ->capacity());
?>
|
Output:
int(8)
int(100)
Reference: http://php.net/manual/en/ds-vector.capacity.php
Last Updated :
22 Aug, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...