PHP Ds\PriorityQueue allocate() Function Last Updated : 23 Aug, 2019 Comments Improve Suggest changes 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: http://php.net/manual/en/ds-priorityqueue.allocate.php Comment More infoAdvertise with us Next Article PHP Ds\PriorityQueue allocate() Function gopaldave Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_priorityqueue Similar Reads PHP SplPriorityQueue compare() Function The SplPriorityQueue::compare() function is an inbuilt function in PHP which is used to compare the priority queue elements to place at a particular order in the heap data structure. Syntax: int SplPriorityQueue::compare( mixed $priority1 , mixed $priority2 ) Parameters: This function accepts two pa 2 min read PHP SplPriorityQueue extract() Function The SplPriorityQueue::extract() function is an inbuilt function in PHP which is used to extract a node from top of the heap and sift up. Syntax: mixed SplPriorityQueue::extract() Parameters: This function does not accept any parameter. Return Value: This function returns the value/priority (or both) 1 min read PHP SplPriorityQueue count() Function The SplPriorityQueue::count() function is an inbuilt function in PHP which is used to count the number of elements in the queue. Syntax: int SplPriorityQueue::count() Parameters: This function does not accept any parameters. Return Value: This function returns the number of elements in the queue. Ex 1 min read PHP SplPriorityQueue current() Function The SplPriorityQueue::current() function is an inbuilt function in PHP which is used to return the current node pointed by the iterator. Syntax: mixed SplPriorityQueue::current() Parameters: This function does not accept any parameter. Return Value: This function returns the value/priority of the cu 1 min read PHP | DsSet allocate() Function The Ds\Set::allocate() function is an inbuilt function in PHP which is used to allocate memory for required capacity. Syntax: void public Ds\Set::allocate( $capacity ) Parameters: This function accepts single parameter $capacity which holds the value of capacity to be allocated. Capacity always roun 1 min read PHP SplPriorityQueue key() Function The SplPriorityQueue::key() function is an inbuilt function in PHP that is used to return the current node index. Syntax: mixed SplPriorityQueue::key() Parameters: This function does not accept any parameter. Return Value: This function returns the current node index. Example: PHP <?php // Declar 1 min read PHP DsQueue 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 SplPriorityQueue next() Function The SplPriorityQueue::next() function is an inbuilt function in PHP that is used to extract the top node from the queue. Syntax: void SplPriorityQueue::next() Parameters: This function does not accept any parameter. Return Value: This function does not return any value. Example: PHP <?php // Decl 1 min read PHP | DsDeque allocate() Function 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 singl 1 min read PHP | DsStack allocate() Function The Ds\Stack::allocate() function is an inbuilt function in PHP which is used to allocate memory for required capacity. This function allocates sufficient memory for a given capacity of an instance of Stack class.Syntax: void Ds\Stack::allocate( $capacity ) Parameters: This function accepts a single 2 min read Like