PriorityQueueTKey, TValue Class

A priority queue. It will return the value with the hightest priority/key first. Multiple occurences of the same priority/key is allowed.

You can update the priority of an element in the priority queue, thereby reposition it in the queue. Save the PriorityQueueTKey, TValueNode returned by Enqueue(TKey, TValue), and updated the value by setting the Key.

Remarks

It is based on a balanced heap data structure (a list handled as a tree structure).

In cases where priority value equals, it does first-in-first-out.

Performance: It has O(log(n)) enqueueing, dequeueing and updating of key.

Definition

Namespace: DHI.Mike1D.Generic
Assembly: DHI.Mike1D.Generic (in DHI.Mike1D.Generic.dll) Version: 24.0.0.0 (11.1.1.1111)
C#
public class PriorityQueue<TKey, TValue>
Inheritance
Object    PriorityQueueTKey, TValue

Type Parameters

TKey

[Missing <typeparam name="TKey"/> documentation for "T:DHI.Mike1D.Generic.PriorityQueue`2"]

TValue

[Missing <typeparam name="TValue"/> documentation for "T:DHI.Mike1D.Generic.PriorityQueue`2"]

Constructors

PriorityQueueTKey, TValue Create a priority queue using the default comparer for the TKey.
PriorityQueueTKey, TValue(IComparerTKey) Create a priority queue and use the provided comparer for the keys.

Properties

Count Current number of elements in queue
First Take a look at the first element in the queue, without dequeue'ing
FirstNode Take a look at the first element in the queue, without dequeue'ing, returning the priority key node

Methods

Clear Clears and empties queue.
Clone Make a clone of the priority queue. It makes a full clone of the queue structure, but the values and keys in the queue are not cloned.
Dequeue Take the first element out of the queue and return it. the first element is the one with the largest key.
Enqueue Add a new element to the queue, with the given priority
EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
FindFirstNodeAfter Finds the first node in the priority queue which comes after any node having the provided key, i.e. the node with the largest key value less than the provided key value.

It does a tree search, and should only be used to find key values that are close to the root key, example queue.FindeFirstNodeAfter(queue.FirstNode.Key)

GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
ToArray Copies the elements of the priority queue to a new array, sorts it and returns it in priority order.

This is an O(n log(n)) operation

ToNodeArray Copies the nodes of the priority queue to a new array, sorts it and returns it in priority order.

This is an O(n log(n)) operation

ToStringReturns a string that represents the current object.
(Inherited from Object)

See Also