Click or drag to resize
DigitalRunePriorityQueueT Class
Represents a queue of values where the greatest item can be accessed quickly.
Inheritance Hierarchy
SystemObject
  DigitalRune.CollectionsPriorityQueueT

Namespace: DigitalRune.Collections
Assembly: DigitalRune (in DigitalRune.dll) Version: 1.20.0.0 (1.20.1.14552)
Syntax
public class PriorityQueue<T> : ICollection<T>, 
	IEnumerable<T>, IEnumerable, ICollection

Type Parameters

T
The type of items in this collection.

The PriorityQueueT type exposes the following members.

Constructors
  NameDescription
Public methodPriorityQueueT
Initializes a new instance of the PriorityQueueT class.
Public methodPriorityQueueT(IComparerT)
Initializes a new instance of the PriorityQueueT class.
Public methodPriorityQueueT(ComparisonT)
Initializes a new instance of the PriorityQueueT class.
Top
Methods
  NameDescription
Public methodClear
Clears this queue.
Public methodContains
Determines whether the queue contains the specified item.
Public methodCopyTo
Copies the elements of the PriorityQueueT to an Array, starting at a particular Array index.
Public methodDequeue
Gets the greatest item in the queue and removes the item.
Public methodEnqueue
Adds the specified item to the queue
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetEnumerator
Returns an enumerator that iterates through a collection.
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodPeek
Gets the greatest item in the queue without removing the item.
Public methodRemove
Removes the specified item.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodTrimExcess
Sets the capacity of the PriorityQueueT to a value suitable for the current number of elements in the set.
Top
Extension Methods
  NameDescription
Public Extension MethodAddRangeT (Defined by CollectionHelper.)
Public Extension MethodDoT(ActionT)Overloaded.
Performs the given action on each element in a sequence when it is enumerated.
(Defined by LinqHelper.)
Public Extension MethodDoT(ActionT, Int32)Overloaded.
Performs the given action on each element (incorporating its index) in a sequence when it is enumerated.
(Defined by LinqHelper.)
Public Extension MethodForEachT(ActionT)Overloaded.
Immediately performs the given action on each element in a sequence.
(Defined by LinqHelper.)
Public Extension MethodForEachT(ActionT, Int32)Overloaded.
Immediately performs the given action on each element (incorporating its index) in a sequence.
(Defined by LinqHelper.)
Public Extension MethodIndexOfT
Returns the index of the first element in a sequence that satisfies the specified condition.
(Defined by LinqHelper.)
Top
Properties
  NameDescription
Public propertyComparer
Public propertyCount
Gets the number of items contained in the PriorityQueueT.
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implementationPrivate methodICollectionTAdd
Adds the specified item. (Same as Enqueue(T).)
Explicit interface implementationPrivate methodICollectionCopyTo
Copies the elements of the ICollection to an Array, starting at a particular Array index.
Explicit interface implementationPrivate methodIEnumerableTGetEnumerator
Returns an enumerator that iterates through a collection.
Explicit interface implementationPrivate methodIEnumerableGetEnumerator
Returns an enumerator that iterates through a collection.
Explicit interface implementationPrivate propertyICollectionTIsReadOnly
Explicit interface implementationPrivate propertyICollectionIsSynchronized
Gets a value indicating whether access to the ICollection is synchronized (thread safe).
Explicit interface implementationPrivate propertyICollectionSyncRoot
Gets an object that can be used to synchronize access to the PriorityQueueT.
Top
Remarks

This class implements a heap-based priority queue. Items can be added with Enqueue(T) (runtime complexity O(log n)). Peek can be used to return the greatest item in the queue without removing the item (runtime complexity O(1)). Dequeue returns the greatest item and also removes it from the queue (runtime complexity O(log n)).

Important: The enumerator (see GetEnumerator) returns the items in an arbitrary order - not sorted by priority!

See Also