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 // Declare Deque of default size $deq = new \Ds\Deque(); // Display the capacity of Deque var_dump($deq->capacity()); // Allocating space for 50 values // to the Deque $deq->allocate(50); // Display the capacity of Deque var_dump($deq->capacity()); ?> |
int(8) int(64)
Program 2:
<?php // Declare Deque of default size $deck = new \Ds\Deque(); // Display the Deque capacity var_dump($deck->capacity()); // Allocating space for 50 values // to the Deque $deck->allocate(50); // Display the Deque capacity var_dump($deck->capacity()); // Allocating space for 60 values // to the Deque $deck->allocate(60); // Display the Deque capacity var_dump($deck->capacity()); ?> |
int(8) int(64) int(64)
Reference: http://php.net/manual/en/ds-deque.allocate.php
Recommended Posts:
- PHP | Ds\Set allocate() Function
- PHP | Ds\Vector allocate() Function
- PHP | Ds\Sequence allocate() Function
- PHP Ds\PriorityQueue allocate() Function
- PHP Ds\Queue allocate() Function
- PHP | Ds\Map allocate() Function
- PHP | Ds\Stack allocate() Function
- How to get the function name inside a function in PHP ?
- PHP 5 vs PHP 7
- PHP | Get PHP configuration information using phpinfo()
- PHP | php.ini File Configuration
- How to import config.php file in a PHP script ?
- PHP | imagecreatetruecolor() Function
- PHP | fpassthru( ) Function
- PHP | ImagickDraw getTextAlignment() Function
- PHP | Ds\Sequence last() Function
- PHP | Imagick floodFillPaintImage() Function
- Function to escape regex patterns before applied in PHP
- PHP | array_udiff_uassoc() Function
- PHP | geoip_continent_code_by_name() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

