The queue.isNotEmpty
function in Dart is used to check if a queue is empty. queue.isNotEmpty
returns true
if the queue is not empty. Otherwise, it returns false
.
The image below shows the visual representation of the queue.isNotEmpty
function.
The
dart:collection
module is required in order to use thequeue.isNotEmpty
function.
bool queue.isNotEmpty
queue
is the name of the queue.
The queue.isNotEmpty
function does not require any parameters.
If the queue is not empty, the queue.isNotEmpty
function returns true
. Otherwise, it returns false
.
The following code shows how to use the queue.isNotEmpty
function in Dart.
import 'dart:convert';import 'dart:collection';void main() {Queue<int> queue_1 = new Queue<int>();queue_1.add(1);queue_1.add(3);queue_1.add(5);queue_1.add(2);queue_1.add(0);//Queue filled= 1->3->5->2->0print("queue_1 is not empty: ${queue_1.isNotEmpty}");//Queue emptyQueue<int> queue_2 = new Queue<int>();print("queue_2 is not empty: ${queue_2.isNotEmpty}");}