Open In App

PHP Ds\PriorityQueue capacity() Function

Improve
Improve
Like Article
Like
Save
Share
Report

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



Last Updated : 23 Aug, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads