pop method
Removes and returns the top priority element from the queue. Time complexity: O(log N). Throws a StateError if the queue is empty.
Implementation
T pop() {
if (empty) {
throw StateError('Cannot pop from an empty PriorityQueue');
}
if (_heap.length == 1) {
return _heap.removeLast();
}
final result = _heap[0];
_heap[0] = _heap.removeLast();
_siftDown(0);
return result;
}