Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

PHP Ds\PriorityQueue capacity() Function

  • Last Updated : 23 Aug, 2019

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
Recommended Articles
Page :

Start Your Coding Journey Now!