Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

PHP Ds\PriorityQueue capacity() Function

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The Ds\PriorityQueue::capacity() Function in PHP is used to check the current capacity of a PriorityQueue instance.

Syntax:

int public Ds\PriorityQueue::capacity ( void )

Parameters: This function does not accepts any parameters.

Return Value: This function returns the current capacity of the PriorityQueue instance.

Below programs illustrate the Ds\PriorityQueue::capacity() Function in PHP:

Program 1:




<?php 
  
// Declare new PriorityQueue 
$pq = new \Ds\PriorityQueue(); 
  
// Use capacity() function 
// to check the current capacity
var_dump($pq->capacity()); 
  
?> 


Output:

int(8)

Program 2:




<?php 
  
// Declare new PriorityQueue 
$pq = new \Ds\PriorityQueue(); 
  
echo("Current Capacity is: "); 
  
// Use capacity() function 
// to check the current capacity
var_dump($pq->capacity()); 
  
echo("Current Capacity 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:

Current Capacity is: int(8)
Current Capacity is: int(8)
int(128)

Reference: http://php.net/manual/en/ds-priorityqueue.capacity.php


My Personal Notes arrow_drop_up
Last Updated : 23 Aug, 2019
Like Article
Save Article
Similar Reads