PriorityQueue<T> class

An adapter class that provides a Priority Queue (Heap) data structure.

In the C++ STL, std::priority_queue is a container adapter that provides constant time lookup of the largest (by default) element, at the expense of logarithmic insertion and extraction.

By default, this implementation acts as a Max-Heap when types are Comparable.

Constructors

PriorityQueue([int compare(T, T)?])
Creates an empty PriorityQueue.
PriorityQueue.from(Iterable<T> elements, [int compare(T, T)?])
Creates a PriorityQueue containing the elements of the given iterable.

Properties

empty bool
Returns true if the priority queue is empty.
no setter
hashCode int
The hash code for this object.
no setteroverride
isNotEmpty bool
Returns true if the priority queue is not empty.
no setter
length int
Alias for generic Dart collection length.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size int
Returns the number of elements in the priority queue.
no setter
top → T
Returns the top priority element without removing it. Time complexity: O(1). Throws a StateError if the queue is empty.
no setter

Methods

clear() → void
Clears the priority queue.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pop() → T
Removes and returns the top priority element from the queue. Time complexity: O(log N). Throws a StateError if the queue is empty.
push(T value) → void
Pushes an element into the priority queue. Time complexity: O(log N).
swap(PriorityQueue<T> other) → void
Exchanges the contents of this priority queue with those of other.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override