Calls action
for each entry object of this double-linked queue.
Each element of the queue has an associated DoubleLinkedQueueEntry.
This method iterates the entry objects from first to last and calls
action
with each object in turn.
The entry objects can also be accessed using firstEntry and lastEntry,
and iterated using DoubleLinkedQueueEntry.nextEntry()
and
DoubleLinkedQueueEntry.previousEntry()
.
The action
function can use methods on DoubleLinkedQueueEntry to remove
the entry or it can insert elements before or after then entry.
If the current entry is removed, iteration continues with the entry that
was following the current entry when action
was called. Any elements
inserted after the current element before it is removed will not be
visited by the iteration.
Source
void forEachEntry(void action(DoubleLinkedQueueEntry<E> element)) { _DoubleLinkedQueueEntry<E> entry = _sentinel._nextLink; while (!identical(entry, _sentinel)) { _DoubleLinkedQueueElement<E> element = entry; _DoubleLinkedQueueEntry<E> next = element._nextLink; // Remember both entry and entry._nextLink. // If someone calls `element.remove()` we continue from `next`. // Otherwise we use the value of entry._nextLink which may have been // updated. action(element); if (identical(this, entry._queue)) { next = entry._nextLink; } else if (!identical(this, next._queue)) { throw new ConcurrentModificationError(this); } entry = next; } }