Make DoubleLinkedQueue.firstEntry/lastEntry nullable again.
It was migrated to null-safety by throwing, but that's an unnecessary breaking change.
Change-Id: I92c21d7518bf7c291b333b33a04eb4b21b7cc210
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134725
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
diff --git a/sdk/lib/collection/queue.dart b/sdk/lib/collection/queue.dart
index 151edc4..f51cdb5 100644
--- a/sdk/lib/collection/queue.dart
+++ b/sdk/lib/collection/queue.dart
@@ -400,11 +400,13 @@
/// The entry object of the first element in the queue.
///
/// Each element of the queue has an associated [DoubleLinkedQueueEntry].
- /// Returns the entry object corresponding to the first element of the queue.
+ ///
+ /// Returns the entry object corresponding to the first element of the queue,
+ /// or `null` if the queue is empty.
///
/// The entry objects can also be accessed using [lastEntry],
- /// and they can be iterated using [DoubleLinkedQueueEntry.nextEntry()] and
- /// [DoubleLinkedQueueEntry.previousEntry()].
+ /// and they can be iterated using [DoubleLinkedQueueEntry.nextEntry] and
+ /// [DoubleLinkedQueueEntry.previousEntry].
DoubleLinkedQueueEntry<E> firstEntry() {
return _sentinel.nextEntry();
}
@@ -412,11 +414,13 @@
/// The entry object of the last element in the queue.
///
/// Each element of the queue has an associated [DoubleLinkedQueueEntry].
- /// Returns the entry object corresponding to the last element of the queue.
+ ///
+ /// Returns the entry object corresponding to the last element of the queue,
+ /// or `null` if the queue is empty.
///
/// The entry objects can also be accessed using [firstEntry],
- /// and they can be iterated using [DoubleLinkedQueueEntry.nextEntry()] and
- /// [DoubleLinkedQueueEntry.previousEntry()].
+ /// and they can be iterated using [DoubleLinkedQueueEntry.nextEntry] and
+ /// [DoubleLinkedQueueEntry.previousEntry].
DoubleLinkedQueueEntry<E> lastEntry() {
return _sentinel.previousEntry();
}
diff --git a/sdk_nnbd/lib/collection/queue.dart b/sdk_nnbd/lib/collection/queue.dart
index 217b2d3..9daafb1 100644
--- a/sdk_nnbd/lib/collection/queue.dart
+++ b/sdk_nnbd/lib/collection/queue.dart
@@ -412,25 +412,29 @@
/// The entry object of the first element in the queue.
///
/// Each element of the queue has an associated [DoubleLinkedQueueEntry].
- /// Returns the entry object corresponding to the first element of the queue.
+ ///
+ /// Returns the entry object corresponding to the first element of the queue,
+ /// or `null` if the queue is empty.
///
/// The entry objects can also be accessed using [lastEntry],
- /// and they can be iterated using [DoubleLinkedQueueEntry.nextEntry()] and
- /// [DoubleLinkedQueueEntry.previousEntry()].
- DoubleLinkedQueueEntry<E> firstEntry() {
- return _sentinel.nextEntry()!;
+ /// and they can be iterated using [DoubleLinkedQueueEntry.nextEntry] and
+ /// [DoubleLinkedQueueEntry.previousEntry].
+ DoubleLinkedQueueEntry<E>? firstEntry() {
+ return _sentinel.nextEntry();
}
/// The entry object of the last element in the queue.
///
/// Each element of the queue has an associated [DoubleLinkedQueueEntry].
- /// Returns the entry object corresponding to the last element of the queue.
+ ///
+ /// Returns the entry object corresponding to the last element of the queue,
+ /// or `null` if the queue is empty.
///
/// The entry objects can also be accessed using [firstEntry],
- /// and they can be iterated using [DoubleLinkedQueueEntry.nextEntry()] and
- /// [DoubleLinkedQueueEntry.previousEntry()].
- DoubleLinkedQueueEntry<E> lastEntry() {
- return _sentinel.previousEntry()!;
+ /// and they can be iterated using [DoubleLinkedQueueEntry.nextEntry] and
+ /// [DoubleLinkedQueueEntry.previousEntry].
+ DoubleLinkedQueueEntry<E>? lastEntry() {
+ return _sentinel.previousEntry();
}
bool get isEmpty {