The Ds\PriorityQueue::allocate() Function in PHP is used to allocate memory for a PriorityQueue class instance. This function allocates sufficient memory for a given capacity for an instance of PriorityQueue class.
Syntax:
void public Ds\PriorityQueue::allocate ( int $capacity )
Parameters: This function accepts a single parameter $capacity which is an integral value denoting the number of values for which capacity is needed to be allocated.
Return Value: This method does not returns any value.
Below programs illustrate the Ds\PriorityQueue::allocate() Function in PHP:
Program 1:
<?php // Declare new PriorityQueue $pq = new \Ds\PriorityQueue(); echo("Allocated Space is: "); // Use capacity() function var_dump($pq->capacity()); echo("Allocated space is: "); // Use allocate() function to // allocate capacity $pq->allocate(50); // Display the allocated vector // capacity var_dump($pq->capacity()); ?> |
Allocated Space is: int(8) Allocated space is: int(64)
Program 2:
<?php // Declare new PriorityQueue $pq = new \Ds\PriorityQueue(); echo("Allocated Space is: "); // Use capacity() function var_dump($pq->capacity()); echo("Allocated space is: "); // Use allocate() function to // allocate capacity $pq->allocate(5); // Display the allocated vector // capacity var_dump($pq->capacity()); // Use allocate() function to // allocate capacity $pq->allocate(120); // Display the allocated vector // capacity var_dump($pq->capacity()); ?> |
Allocated Space is: int(8) Allocated space is: int(8) int(128)
Reference: http://php.net/manual/en/ds-priorityqueue.allocate.php
Recommended Posts:
- PHP | Ds\Map allocate() Function
- PHP | Ds\Set allocate() Function
- PHP | Ds\Deque allocate() Function
- PHP | Ds\Stack allocate() Function
- PHP Ds\Queue allocate() Function
- PHP | Ds\Sequence allocate() Function
- PHP | Ds\Vector allocate() Function
- How to get the function name inside a function in PHP ?
- PHP | Ds\Map get() Function
- PHP | end() Function
- PHP | pow( ) Function
- PHP | next() Function
- PHP | Ds\Set last() Function
- PHP | Ds\Set add() Function
- PHP | Ds\Set first() Function
- PHP | Ds\Map first() Function
- PHP | ord() Function
- PHP | pi( ) Function
- PHP Ds\Map sum() Function
- PHP | max( ) 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.

