• PHP Video Tutorials

PHP - Ds Sequence capacity() Function


Advertisements

Ds\Sequence::capacity() function can return the current capacity.

Syntax

public abstract int Ds\Sequence::capacity( void )

Ds\Sequence::capacity() function doesn't have any parameters and can return the current capacity.

Example 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());
?>

Example 2

<?php 
   $seq = new \Ds\Vector();
   
   $seq->push(...range(1, 50)); 
   var_dump($seq->capacity());
  
   $seq->push(...range(1, 100));
   var_dump($seq->capacity()); 
?>
php_function_reference.htm
Advertisements