removeFirst method

  1. @override
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 the comparison constructor parameter.

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


E removeFirst() {
  if (_length == 0) throw StateError('No element');
  var result = _elementAt(0);
  var last = _removeLast();
  if (_length > 0) {
    _bubbleDown(last, 0);
  return result;