enqueue method
void
enqueue(
- RunFunction? run, {
- int priority = 0,
- dynamic key,
})
override
Implementation
@override
void enqueue(run, { int priority = 0, dynamic? key }) {
_PriorityQueueOptions element = _PriorityQueueOptions(
priority,
run: run,
key: key,
);
if (key != null) {
if (_map[key] != null) {
throw Exception('keyed entry allready exists');
}
_map[key] = element;
}
if (size > 0 && _queue[size - 1].priority >= priority) {
_queue.add(element);
return;
}
int index = lowerBound<_PriorityQueueOptions>(
_queue,
element,
(a, b) => b.priority - a.priority);
_queue.insert(index, element);
}