Friday, September 27, 2024
Google search engine
HomeLanguagesPHP DsPriorityQueue capacity() Function

PHP Ds\PriorityQueue capacity() Function

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

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments