PHP中Ds \ PriorityQueue類的isEmpty()函數用於確定特定的PriorityQueue實例是否為空。如果PriorityQueue為空,則返回True,否則返回False。
用法:
bool isEmpty( )
參數:此函數不接受任何參數。
返回值:此函數根據此PriorityQueue是否為空返回布爾值。如果PriorityQueue為空,則返回True,否則返回False。
以下示例程序旨在說明上述方法:
程序1::
<?php
// Declare new PriorityQueue
$pq = new \Ds\PriorityQueue();
// Initially PriorityQueue is Empty
var_dump($pq->isEmpty());
// Add elements to the PriorityQueue
$pq->push("One", 1);
$pq->push("Two", 2);
$pq->push("Three", 3);
// Check again if the PriorityQueue
// is Empty
var_dump($pq->isEmpty());
?>
輸出:
bool(true) bool(false)
程序2:
<?php
// Declare new PriorityQueue
$pq = new \Ds\PriorityQueue();
// Initially PriorityQueue is Empty
var_dump($pq->isEmpty());
// Add elements to the PriorityQueue
$pq->push("Geeks", 1);
$pq->push("for", 2);
$pq->push("Geeks", 3);
// Check again if the PriorityQueue
// is Empty
var_dump($pq->isEmpty());
?>
輸出:
bool(true) bool(false)
參考:http://php.net/manual/en/ds-priorityqueue.isempty.php
相關用法
- PHP Ds\Set isEmpty()用法及代碼示例
- PHP Ds\Map isEmpty()用法及代碼示例
- PHP Ds\Collection isEmpty()用法及代碼示例
- PHP Ds\Deque isEmpty()用法及代碼示例
- PHP Ds\Vector isEmpty()用法及代碼示例
- PHP Ds\Queue isEmpty()用法及代碼示例
- PHP Ds\Stack isEmpty()用法及代碼示例
- PHP SplDoublyLinkedList isEmpty()用法及代碼示例
- PHP Ds\Set add()用法及代碼示例
- PHP each()用法及代碼示例
- PHP end()用法及代碼示例
- PHP next()用法及代碼示例
- PHP min( )用法及代碼示例
- PHP max( )用法及代碼示例
注:本文由純淨天空篩選整理自gopaldave大神的英文原創作品 PHP Ds\PriorityQueue isEmpty() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。