HeapPriorityQueue<E> constructor

HeapPriorityQueue<E>([
  1. int comparison(
    1. E,
    2. E
    )?
])

Create a new priority queue.

The comparison is a Comparator used to compare the priority of elements. An element that compares as less than another element has a higher priority.

If comparison is omitted, it defaults to Comparable.compare. If this is the case, E must implement Comparable, and this is checked at runtime for every comparison.

Implementation

HeapPriorityQueue([int Function(E, E)? comparison])
    : comparison = comparison ?? defaultCompare;