Ds \ Deque::isEmpty()函數是PHP中的內置函數,用於檢查Deque是否為空。
用法:
public Ds\Deque::isEmpty( void ):bool
參數:該函數不接受任何參數。
返回值:如果雙端隊列為空,則此函數返回true,否則返回false。
以下示例程序旨在說明PHP中的Ds \ Deque::isEmpty()函數:
程序1:
<?php
// Declare a deque
$deck = new \Ds\Deque([1, 2, 3, 4, 5, 6]);
echo("Original Deque\n");
// Display the Deque elements
print_r($deck);
// Use isEmpty() function to check
// the deque is empty or not
var_dump($deck->isEmpty());
?>
輸出:
Original Deque Ds\Deque Object ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 ) bool(false)
程序2:
<?php
// Declare a deque
$deck = new \Ds\Deque([1, 2, 3, 4, 5, 6]);
echo("Original Deque\n");
// Display the Deque elements
print_r($deck);
// Clearing the Deque
$deck->clear();
// Use isEmpty() function to check
// the deque is empty or not
var_dump($deck->isEmpty());
?>
輸出:
Original Deque Ds\Deque Object ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 ) bool(true)
參考: http://php.net/manual/en/ds-deque.isempty.php
相關用法
- PHP Ds\Set isEmpty()用法及代碼示例
- PHP Ds\Map isEmpty()用法及代碼示例
- PHP Ds\Collection isEmpty()用法及代碼示例
- PHP Ds\Stack isEmpty()用法及代碼示例
- PHP SplDoublyLinkedList isEmpty()用法及代碼示例
- PHP Ds\PriorityQueue isEmpty()用法及代碼示例
- PHP Ds\Queue isEmpty()用法及代碼示例
- PHP Ds\Vector isEmpty()用法及代碼示例
- Underscore.js _.isEmpty()用法及代碼示例
- PHP tan( )用法及代碼示例
- d3.js d3.mean()用法及代碼示例
- PHP pos()用法及代碼示例
注:本文由純淨天空篩選整理自barykrg大神的英文原創作品 PHP | Ds\Deque isEmpty() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。