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

Related Articles

PHP Ds\Queue capacity() Function

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

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

Syntax:  

int public Ds\Queue::capacity ( void )

Parameters: This function does not accepts any parameters.

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

Below programs illustrate the Ds\Queue::capacity() function in PHP:

Program 1:  

PHP




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


Output: 

int(8)




 

Program 2: 

PHP




<?php
 
// Declare new Queue
$q = new \Ds\Queue();
 
echo("Current Capacity is: ");
 
// Use capacity() function
// to check the current capacity
var_dump($q->capacity());
 
echo("Current Capacity is: ");
 
// Use allocate() function to
// allocate capacity
$q->allocate(5);
 
// Display the allocated vector
// capacity
var_dump($q->capacity());
 
// Use allocate() function to
// allocate capacity
$q->allocate(120);
 
// Display the allocated vector
// capacity
var_dump($q->capacity());
 
?>


Output: 

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




 

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


My Personal Notes arrow_drop_up
Last Updated : 09 Nov, 2020
Like Article
Save Article
Similar Reads