removeFirst method Null safety

  1. @override
E removeFirst()
override

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.

Implementation

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