The Ds\Deque::allocate() function is an inbuilt function in PHP which is used to allocate memory as specified in the argument. If the argument is not defined, then the Deque of default size will be created.
Syntax:
public Ds\Deque::allocate( $capacity ) : void
Parameters: This function accepts single parameter $capacity which holds the number of values for which space is to be allocated.
Return Value: This function does not return any value.
Below programs illustrate the Ds\Deque::allocate() function in PHP:
Program 1:
<?php
$deq = new \Ds\Deque();
var_dump( $deq ->capacity());
$deq ->allocate(50);
var_dump( $deq ->capacity());
?>
|
Program 2:
<?php
$deck = new \Ds\Deque();
var_dump( $deck ->capacity());
$deck ->allocate(50);
var_dump( $deck ->capacity());
$deck ->allocate(60);
var_dump( $deck ->capacity());
?>
|
Output:
int(8)
int(64)
int(64)
Reference: http://php.net/manual/en/ds-deque.allocate.php