PriorityQueue<E> class
abstract
A priority queue is a priority based work-list of elements.
The queue allows adding elements, and removing them again in priority order.
The same object can be added to the queue more than once.
There is no specified ordering for objects with the same priority
(where the comparison
function returns zero).
Operations which care about object equality, contains and remove,
use Object.== for testing equality.
In most situations this will be the same as identity (identical),
but there are types, like String, where users can reasonably expect
distinct objects to represent the same value.
If elements override Object.==, the comparison
function must
always give equal objects the same priority,
otherwise contains or remove might not work correctly.
- Implementers
Constructors
- PriorityQueue([int comparison(E, E)?])
-
Creates an empty PriorityQueue.
factory
Properties
- first → E
-
Returns the next element that will be returned by removeFirst.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Whether the queue is empty.
no setter
- isNotEmpty → bool
-
Whether the queue has any elements.
no setter
- length → int
-
Number of elements in the queue.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
unorderedElements
→ Iterable<
E> -
Provides efficient access to all the elements currently in the queue.
no setter
Methods
-
add(
E element) → void - Adds element to the queue.
-
addAll(
Iterable< E> elements) → void -
Adds all
elements
to the queue. -
clear(
) → void - Removes all the elements from this queue.
-
contains(
E object) → bool -
Checks if
object
is in the queue. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
remove(
E element) → bool -
Removes an element of the queue that compares equal to
element
. -
removeAll(
) → Iterable< E> - Removes all the elements from this queue and returns them.
-
removeFirst(
) → E - Removes and returns the element with the highest priority.
-
toList(
) → List< E> - Returns a list of the elements of this queue in priority order.
-
toSet(
) → Set< E> - Return a comparator based set using the comparator of this queue.
-
toString(
) → String -
A string representation of this object.
inherited
-
toUnorderedList(
) → List< E> - Returns a list of the elements of this queue in no specific order.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited