Skip to content

Commit 76b18c4

Browse files
lrhncommit-bot@chromium.org
authored andcommitted
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>
1 parent 30151a6 commit 76b18c4

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

sdk/lib/collection/queue.dart

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -400,23 +400,27 @@ class DoubleLinkedQueue<E> extends Iterable<E> implements Queue<E> {
400400
/// The entry object of the first element in the queue.
401401
///
402402
/// Each element of the queue has an associated [DoubleLinkedQueueEntry].
403-
/// Returns the entry object corresponding to the first element of the queue.
403+
///
404+
/// Returns the entry object corresponding to the first element of the queue,
405+
/// or `null` if the queue is empty.
404406
///
405407
/// The entry objects can also be accessed using [lastEntry],
406-
/// and they can be iterated using [DoubleLinkedQueueEntry.nextEntry()] and
407-
/// [DoubleLinkedQueueEntry.previousEntry()].
408+
/// and they can be iterated using [DoubleLinkedQueueEntry.nextEntry] and
409+
/// [DoubleLinkedQueueEntry.previousEntry].
408410
DoubleLinkedQueueEntry<E> firstEntry() {
409411
return _sentinel.nextEntry();
410412
}
411413

412414
/// The entry object of the last element in the queue.
413415
///
414416
/// Each element of the queue has an associated [DoubleLinkedQueueEntry].
415-
/// Returns the entry object corresponding to the last element of the queue.
417+
///
418+
/// Returns the entry object corresponding to the last element of the queue,
419+
/// or `null` if the queue is empty.
416420
///
417421
/// The entry objects can also be accessed using [firstEntry],
418-
/// and they can be iterated using [DoubleLinkedQueueEntry.nextEntry()] and
419-
/// [DoubleLinkedQueueEntry.previousEntry()].
422+
/// and they can be iterated using [DoubleLinkedQueueEntry.nextEntry] and
423+
/// [DoubleLinkedQueueEntry.previousEntry].
420424
DoubleLinkedQueueEntry<E> lastEntry() {
421425
return _sentinel.previousEntry();
422426
}

sdk_nnbd/lib/collection/queue.dart

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -412,25 +412,29 @@ class DoubleLinkedQueue<E> extends Iterable<E> implements Queue<E> {
412412
/// The entry object of the first element in the queue.
413413
///
414414
/// Each element of the queue has an associated [DoubleLinkedQueueEntry].
415-
/// Returns the entry object corresponding to the first element of the queue.
415+
///
416+
/// Returns the entry object corresponding to the first element of the queue,
417+
/// or `null` if the queue is empty.
416418
///
417419
/// The entry objects can also be accessed using [lastEntry],
418-
/// and they can be iterated using [DoubleLinkedQueueEntry.nextEntry()] and
419-
/// [DoubleLinkedQueueEntry.previousEntry()].
420-
DoubleLinkedQueueEntry<E> firstEntry() {
421-
return _sentinel.nextEntry()!;
420+
/// and they can be iterated using [DoubleLinkedQueueEntry.nextEntry] and
421+
/// [DoubleLinkedQueueEntry.previousEntry].
422+
DoubleLinkedQueueEntry<E>? firstEntry() {
423+
return _sentinel.nextEntry();
422424
}
423425

424426
/// The entry object of the last element in the queue.
425427
///
426428
/// Each element of the queue has an associated [DoubleLinkedQueueEntry].
427-
/// Returns the entry object corresponding to the last element of the queue.
429+
///
430+
/// Returns the entry object corresponding to the last element of the queue,
431+
/// or `null` if the queue is empty.
428432
///
429433
/// The entry objects can also be accessed using [firstEntry],
430-
/// and they can be iterated using [DoubleLinkedQueueEntry.nextEntry()] and
431-
/// [DoubleLinkedQueueEntry.previousEntry()].
432-
DoubleLinkedQueueEntry<E> lastEntry() {
433-
return _sentinel.previousEntry()!;
434+
/// and they can be iterated using [DoubleLinkedQueueEntry.nextEntry] and
435+
/// [DoubleLinkedQueueEntry.previousEntry].
436+
DoubleLinkedQueueEntry<E>? lastEntry() {
437+
return _sentinel.previousEntry();
434438
}
435439

436440
bool get isEmpty {

0 commit comments

Comments
 (0)