From 4c9a64d515f55e97959441bdbfc43401f81f3da9 Mon Sep 17 00:00:00 2001 From: akulafb Date: Mon, 12 Jan 2026 10:59:48 +0300 Subject: [PATCH 1/2] Adjust explanation for brevity --- .../concepts/queue/terms/isEmpty/isEmpty.md | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 content/dart/concepts/queue/terms/isEmpty/isEmpty.md diff --git a/content/dart/concepts/queue/terms/isEmpty/isEmpty.md b/content/dart/concepts/queue/terms/isEmpty/isEmpty.md new file mode 100644 index 00000000000..3c2dcd65a2c --- /dev/null +++ b/content/dart/concepts/queue/terms/isEmpty/isEmpty.md @@ -0,0 +1,65 @@ +--- +Title: '.isEmpty' +Description: 'Returns true if the queue contains no elements, otherwise returns false.' +Subjects: + - 'Computer Science' + - 'Code Foundations' +Tags: + - 'Dart' + - 'Queues' + - 'Properties' +CatalogContent: + - 'learn-dart' + - 'paths/computer-science' +--- + +In Dart, **`.isEmpty`** is used to check whether any collection of values (not only queue, but also Set/List/Map/etc.) is empty or not, that is - does it have 0 elements? It returns `true` if so and `false` if there's at least one element. This property is part of the `Queue` class under the `dart:collection` library. + +## Syntax + +```pseudo +queue.isEmpty +``` + +- `queue`: The name of the queue to check for emptiness. + +The property returns a boolean value: +- `true`: The queue contains no elements. +- `false`: The queue contains one or more elements. + +## Example + +The following example demonstrates the usage of the `.isEmpty` property. When the Queue is freshly created, **`.isEmpty`** returns `true`. After being populated, it returns `false`. + +```dart +import 'dart:collection'; + +void main() { + Queue values = new Queue(); + + print('Is queue empty? ${values.isEmpty}'); + + values.add(12); + values.add(24); + values.add(36); + + print('Is queue empty? ${values.isEmpty}'); + print('Number of elements: ${values.length}'); + + for(var num in values) { + print(num); + } +} +``` + +Output for the above: + +```shell +Is queue empty? true +Is queue empty? false +Number of elements: 3 +12 +24 +36 +``` + From cd6d9666bab7bac0c1d563193ce983689d4e8476 Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Tue, 13 Jan 2026 12:30:21 +0530 Subject: [PATCH 2/2] Update isEmpty.md for clarity and detail Clarified the explanation of the .isEmpty property for Queue in Dart, including its return values and parameters. --- .../concepts/queue/terms/isEmpty/isEmpty.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/content/dart/concepts/queue/terms/isEmpty/isEmpty.md b/content/dart/concepts/queue/terms/isEmpty/isEmpty.md index 3c2dcd65a2c..f78622aadf2 100644 --- a/content/dart/concepts/queue/terms/isEmpty/isEmpty.md +++ b/content/dart/concepts/queue/terms/isEmpty/isEmpty.md @@ -13,7 +13,7 @@ CatalogContent: - 'paths/computer-science' --- -In Dart, **`.isEmpty`** is used to check whether any collection of values (not only queue, but also Set/List/Map/etc.) is empty or not, that is - does it have 0 elements? It returns `true` if so and `false` if there's at least one element. This property is part of the `Queue` class under the `dart:collection` library. +In Dart, **`.isEmpty`** is a property used to check whether a `Queue` contains any elements. It returns `true` if the queue has zero elements and `false` if it contains one or more elements. This property is available on the `Queue` class from the `dart:collection` library. ## Syntax @@ -23,13 +23,20 @@ queue.isEmpty - `queue`: The name of the queue to check for emptiness. +**Parameters:** + +This property takes no parameters. + +**Return value:** + The property returns a boolean value: -- `true`: The queue contains no elements. -- `false`: The queue contains one or more elements. + +- `true` if the queue contains no elements +- `false` if the queue contains one or more elements ## Example -The following example demonstrates the usage of the `.isEmpty` property. When the Queue is freshly created, **`.isEmpty`** returns `true`. After being populated, it returns `false`. +This example shows that `.isEmpty` returns `true` for an empty queue and `false` after elements are added: ```dart import 'dart:collection'; @@ -52,7 +59,7 @@ void main() { } ``` -Output for the above: +The output of this code is: ```shell Is queue empty? true @@ -62,4 +69,3 @@ Number of elements: 3 24 36 ``` -