The Ds\Sequence::capacity() function is an inbuilt function in PHP which is used to returns the current capacity of sequence.
Syntax:
int abstract public Ds\Sequence::capacity ( void )
Parameter: This function does not accepts any parameter.
Return value: This function returns the current capacity of sequence.
Below programs illustrate the Ds\Sequence::capacity() function in PHP:
Program 1:
<?php
$seq = new \Ds\Vector();
var_dump( $seq ->capacity());
$seq ->push(...range(1, 100));
var_dump( $seq ->capacity());
$seq ->pop();
var_dump( $seq ->capacity());
?>
|
Output:
int(8)
int(100)
int(100)
Program 2:
<?php
$seq = new \Ds\Vector();
$seq ->push(...range(1, 50));
var_dump( $seq ->capacity());
$seq ->push(...range(1, 50));
var_dump( $seq ->capacity());
?>
|
Reference: https://www.php.net/manual/en/ds-sequence.capacity.php