PHP中的Ds \ Queue::capacity()函數用於檢查隊列實例的當前容量。
用法:
int public Ds\PriorityQueue::capacity ( void )
參數:此函數不接受任何參數。
返回值:此函數返回Queue實例的當前容量。
以下示例程序旨在說明PHP中的strong> Ds \ Queue::capacity()函數:
程序1:
<?php
// Declare new Queue
$q = new \Ds\Queue();
// Use capacity() function
// to check the current capacity
var_dump($q->capacity());
?>
輸出:
int(8)
程序2:
<?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());
?>
輸出:
Current Capacity is:int(8) Current Capacity is:int(8) int(128)
參考:http://php.net/manual/en/ds-queue.capacity.php
相關用法
- PHP Ds\Set capacity()用法及代碼示例
- PHP Ds\Map capacity()用法及代碼示例
- PHP Ds\PriorityQueue capacity()用法及代碼示例
- PHP Ds\Deque capacity()用法及代碼示例
- PHP Ds\Sequence capacity()用法及代碼示例
- PHP Ds\Stack capacity()用法及代碼示例
- PHP Ds\Vector capacity()用法及代碼示例
- PHP ord()用法及代碼示例
- PHP max( )用法及代碼示例
- PHP pi( )用法及代碼示例
- PHP Ds\Set xor()用法及代碼示例
- PHP dir()用法及代碼示例
- PHP exp()用法及代碼示例
- PHP pos()用法及代碼示例
注:本文由純淨天空篩選整理自gopaldave大神的英文原創作品 PHP Ds\Queue capacity() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。