PHP Ds\PriorityQueue allocate() Function Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 <?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()); ?> Output: Allocated Space is: int(8) Allocated space is: int(64) Program 2: php <?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()); ?> Output: Allocated Space is: int(8) Allocated space is: int(8) int(128) Reference: https://www.php.net/manual/en/ds-priorityqueue.allocate.php Comment More infoAdvertise with us Next Article PHP Ds\PriorityQueue clear() Function G gopaldave Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_priorityqueue Similar Reads PHP Ds\Queue allocate() Function The Ds\Queue::allocate() Function in PHP is used to allocate memory for a Queue class instance. This function allocates sufficient memory for a given capacity for an instance of Queue class. Syntax: void public Ds\Queue::allocate ( int $capacity ) Parameters: This function accepts a single parameter 2 min read PHP Ds\Queue allocate() Function The Ds\Queue::allocate() Function in PHP is used to allocate memory for a Queue class instance. This function allocates sufficient memory for a given capacity for an instance of Queue class. Syntax: void public Ds\Queue::allocate ( int $capacity ) Parameters: This function accepts a single parameter 2 min read PHP Ds\PriorityQueue clear() Function The Ds\PriorityQueue::clear() Function in PHP is used to clear all of the elements from a PriorityQueue instance. This function just clears the instance without deleting it. Syntax: void public Ds\PriorityQueue::clear ( void ) Parameters: This function does not accepts any parameters. Return Value: 1 min read PHP Ds\PriorityQueue clear() Function The Ds\PriorityQueue::clear() Function in PHP is used to clear all of the elements from a PriorityQueue instance. This function just clears the instance without deleting it. Syntax: void public Ds\PriorityQueue::clear ( void ) Parameters: This function does not accepts any parameters. Return Value: 1 min read PHP Ds\PriorityQueue count() Function The Ds\PriorityQueue::count() Function in PHP is used to get the count of elements present in a Priority Queue instance. Syntax: int public Ds\PriorityQueue::count( void ) Parameters: This function does not accepts any parameters. Return Value: This function calculates the number of elements present 1 min read PHP Ds\PriorityQueue count() Function The Ds\PriorityQueue::count() Function in PHP is used to get the count of elements present in a Priority Queue instance. Syntax: int public Ds\PriorityQueue::count( void ) Parameters: This function does not accepts any parameters. Return Value: This function calculates the number of elements present 1 min read Like