The Ds\Deque::isEmpty() function is an inbuilt function in PHP which is used to check the Deque is empty or not.
Syntax:
PHP
PHP
public Ds\Deque::isEmpty( void ) : boolParameters: This function does not accept any parameter. Return Value: This function returns true if the Deque is empty, else return false. Below programs illustrate the Ds\Deque::isEmpty() function in PHP: Program 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());
?>
Output:
Program 2:
Original Deque
Ds\Deque Object
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
)
bool(false)
<?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());
?>
Output:
Reference: https://www.php.net/manual/en/ds-deque.isempty.php
Original Deque
Ds\Deque Object
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
)
bool(true)