removeFirst method

V? removeFirst()

Removes and returns the next item in priority order (front of the first queue), or null when the map is empty. Empty queues are pruned.

Implementation

V? removeFirst() {
  if (_queues.isEmpty) return null;
  final entry = _queues.entries.firstOrNull;
  if (entry == null) return null;
  final List<V> q = entry.value;
  final V v = q.removeAt(0);
  final K key = entry.key;
  if (q.isEmpty) _queues.remove(key);
  return v;
}