Ds \ Stack::capacity()函數是PHP中的一個內置函數,用於返回堆棧的當前容量。
用法:
int Ds\Stack::capacity( void )
參數:該函數不接受任何參數。
返回值:此函數返回堆棧的當前容量。
以下示例程序旨在說明PHP中的Ds \ Stack::capacity()函數:
程序1:
<?php
// Declare new Stack
$stack = new \Ds\Stack();
// Use capacity() function to check
// the current capacity
var_dump($stack->capacity());
?>
輸出:
int(8)
程序2:
<?php
// Declare new Stack
$stack = new \Ds\Stack();
echo("Current Capacity is:");
// Use capacity() function
// to check the current capacity
var_dump($stack->capacity());
echo("Current Capacity is:");
// Use allocate() function to
// allocate capacity
$stack->allocate(5);
// Display the allocated vector
// capacity
var_dump($stack->capacity());
echo("Current Capacity is:");
// Use allocate() function to
// allocate capacity
$stack->allocate(120);
// Display the allocated vector
// capacity
var_dump($stack->capacity());
?>
輸出:
Current Capacity is:int(8) Current Capacity is:int(8) Current Capacity is:int(120)
參考: https://www.php.net/manual/en/ds-stack.capacity.php
相關用法
- PHP Ds\Set capacity()用法及代碼示例
- PHP Ds\Map capacity()用法及代碼示例
- PHP Ds\Vector capacity()用法及代碼示例
- PHP Ds\Sequence capacity()用法及代碼示例
- PHP Ds\PriorityQueue capacity()用法及代碼示例
- PHP Ds\Queue capacity()用法及代碼示例
- PHP Ds\Deque capacity()用法及代碼示例
- p5.js value()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- PHP ord()用法及代碼示例
- p5.js box()用法及代碼示例
- PHP pi( )用法及代碼示例
注:本文由純淨天空篩選整理自jit_t大神的英文原創作品 PHP | Ds\Stack capacity() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。