• PHP Video Tutorials

PHP - Ds\Queue::allocate() Function



Ds\Queue::allocate() function can allocate enough memory for the required capacity.

Syntax

public void Ds\Queue::allocate( int $capacity )

Ds\Queue::allocate() function to ensure that enough memory is allocated for the required capacity. It can remove a need to reallocate an internal as values are added.

Ds\Queue::allocate() function doesn't return any value.

Example

<?php  
   $queue = new \Ds\Queue();  
   
   echo("The allocated space is:");  
   var_dump($queue->capacity());  
   
   echo("The allocated space is:");  
   $queue->allocate(20);  
   var_dump($q->capacity());  
   
   $queue->allocate(100);  
   var_dump($q->capacity());  
?> 
php_function_reference.htm
Advertisements