removeFirst method

E removeFirst ()

Removes and returns the element with the highest priority.

Repeatedly calling this method, without adding element in between, is guaranteed to return elements in non-decreasing order as, specified by comparison.

The queue must not be empty when this method is called.


E removeFirst() {
  if (_length == 0) throw new StateError("No such element");
  E result = _queue[0];
  E last = _removeLast();
  if (_length > 0) {
    _bubbleDown(last, 0);
  return result;