clear 方法

void clear()
override

移除队列中的所有元素。队列的大小变为零。

实现

void clear() {
  var cursor = _sentinel._nextLink!;
  while (true) {
    var entry = cursor._asNonSentinelEntry();
    if (entry == null) break;
    cursor = cursor._nextLink!;
    entry
      .._nextLink = null
      .._previousLink = null
      .._queue = null;
  }
  _sentinel._nextLink = _sentinel;
  _sentinel._previousLink = _sentinel;
  _elementCount = 0;
}