PriorityQueue<T> class

Implements a priority queue using a binary heap. The priority queue is sorted so that the smallest item is removed from the queue first.

public sealed class PriorityQueue<T> : ICollection, IEnumerable<T>
parameter description
T The type of data to be sorted in the priority queue.

Public Members

name description
PriorityQueue() Initializes a new instance of the PriorityQueue class that is empty, has the default initial capacity, and is sorted according to the default Comparer for the type of the data.
PriorityQueue(…) Initializes a new instance of the PriorityQueue class that is empty, has the specified initial capacity, and is sorted according to the default Comparer for the type of the data. (3 constructors)
Capacity { get; set; } Gets or sets the number of elements that the PriorityQueue can contain.
Count { get; } Gets the number of elements contained in the PriorityQueue.
CopyTo(…) Copies the elements of the PriorityQueue to an existing one-dimensional Array, starting at a particular array index.
Dequeue() Removes and returns the smallest item from the PriorityQueue. This operation takes O(log n) time.
Enqueue(…) Adds an object to the PriorityQueue. This operation takes O(log n) time.
Peek() Returns (without removing) the smallest item in the PriorityQueue. This operation takes O(1) time.
Remove(…) Removes the first item equal to item in the priority queue.
RepositionHead() Puts the item at the head of the queue into the correct place. If you modify the item returned by Peek such that its “priority” changes, call this method to restore the correct order in the PriorityQueue.
SwapHead(…) Swaps the item at the head of the queue with a new item. The new item will be placed into the correct location in the priority queue.

See Also