PHP中的Ds \ Queue::isEmpty()函数用于确定特定的Queue实例是否为空。如果队列为空,则返回True,否则返回False。
用法:
bool public Ds\Queue::isEmpty ( void )
参数:该函数不接受任何参数。
返回值:此函数根据此Queue是否为空返回一个布尔值。如果队列为空,则返回True,否则返回False。
以下示例程序旨在说明PHP中的Ds \ Queue::isEmpty()函数:
程序1:
// Declare new Queue
$q = new \Ds\Queue();
// Initially Queue is Empty
var_dump($q->isEmpty());
// Add elements to the Queue
$q->push("One");
$q->push("Two");
$q->push("Three");
// Check again if the Queue
// is Empty
var_dump($q->isEmpty());
?>
输出:
bool(true)
bool(false)
程序2:
// Declare new Queue
$q = new \Ds\Queue();
// Initially Queue is Empty
var_dump($q->isEmpty());
// Add elements to the Queue
$q->push("Geeks");
$q->push("for");
$q->push("Geeks");
// Check again if the Queue
// is Empty
var_dump($q->isEmpty());
?>
输出:
bool(true)
bool(false)