Ds \ Deque::count()函数是PHP中的内置函数,用于获取双端队列中的元素数。
用法:
public Ds\Deque::count( void ):int
参数:该函数不接受任何参数。
返回值:此函数返回双端队列中的元素数。
以下示例程序旨在说明PHP中的Ds \ Deque::count()函数:
程序1:
<?php
// Declare a deque
$deck = new \Ds\Deque([1, 2, 3, 4, 5, 6]);
echo("Elements in the Deque\n");
// Display the Deque elements
print_r($deck);
echo("\nNumber of elements in the Deque:");
print_r($deck->count());
?>
输出:
Elements in the Deque
Ds\Deque Object
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
)
Number of elements in the Deque:6
程序2:
<?php
// Declare a deque
$deck = new \Ds\Deque(["geeks", "for", "geeks"]);
echo("Elements in the Deque\n");
// Display the Deque elements
print_r($deck);
echo("\nNumber of elements in the Deque:");
print_r($deck->count());
?>
输出:
Elements in the Deque
Ds\Deque Object
(
[0] => geeks
[1] => for
[2] => geeks
)
Number of elements in the Deque:3
参考: http://php.net/manual/en/ds-deque.count.php
相关用法
- PHP Ds\Set count()用法及代码示例
- PHP Ds\Map count()用法及代码示例
- PHP count()用法及代码示例
- PHP SplDoublyLinkedList count()用法及代码示例
- PHP ArrayIterator count()用法及代码示例
- PHP SimpleXMLElement count()用法及代码示例
- PHP Ds\Stack count()用法及代码示例
- PHP Ds\PriorityQueue count()用法及代码示例
- PHP SplHeap count()用法及代码示例
- PHP Ds\Vector count()用法及代码示例
- PHP Ds\Queue count()用法及代码示例
- PHP ArrayObject count()用法及代码示例
- PHP SplFixedArray count()用法及代码示例
- PHP SplObjectStorage count()用法及代码示例
注:本文由纯净天空筛选整理自barykrg大神的英文原创作品 PHP | Ds\Deque count() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
