remove方法

bool remove(
  1. Object? o
)
override

从队列中移除单个value实例。

如果移除了值,则返回true,如果队列中不包含等于value的元素,则返回false

实现

bool remove(Object? o) {
  _DoubleLinkedQueueEntry<E> entry = _sentinel._nextLink!;
  while (true) {
    var elementEntry = entry._asNonSentinelEntry();
    if (elementEntry == null) return false;
    bool equals = (elementEntry.element == o);
    if (!identical(this, elementEntry._queue)) {
      // Entry must still be in the queue.
      throw ConcurrentModificationError(this);
    }
    if (equals) {
      entry._remove();
      _elementCount--;
      return true;
    }
    entry = entry._nextLink!;
  }
}