remove method

  1. @override
bool remove(
  1. E element
)
override

Removes an element of the queue that compares equal to element.

Returns true if an element is found and removed, and false if no equal element is found.

If the queue contains more than one object equal to element, only one of them is removed.

Uses the Object.== of elements in the queue to check for whether they are equal to element. Equal objects objects must have the same priority according to the comparison function. That is, if a == b then comparison(a, b) == 0. If that is not the case, this check might fail to find an object.

Implementation

@override
bool remove(E element) {
  var index = _locate(element);
  if (index < 0) return false;
  _modificationCount++;
  var last = _removeLast();
  if (index < _length) {
    var comp = comparison(last, element);
    if (comp <= 0) {
      _bubbleUp(last, index);
    } else {
      _bubbleDown(last, index);
    }
  }
  return true;
}