|
PriorityQueue
The Priority Queue data structure
A Priority Queue and it's major operations. public sealed class PriorityQueue<T> : IVisitableCollection<T>, IQueue<T>
{
// Methods
public void Accept(IVisitor<T> visitor);
public void Add(T item);
public void Add(T item, int priority);
public void Clear();
public void DecreaseItemPriority(int by);
public T Dequeue();
public void Enqueue(T item);
public void Enqueue(T item, int priority);
public IEnumerator<T> GetEnumerator();
public IEnumerator<Association<int, T>> GetKeyEnumerator();
public void IncreaseItemPriority(int by);
public T Peek();
// ...
// Properties
public int Count { get; }
public bool IsEmpty { get; }
// ...
}
A Priority queue is a special type of queue where the item dequeued will always be the smallest (in a Min Priority Queue) or the largest (in a Max Priority Queue) of the items contained in the queue. The underlying representation is implemented using a Min/Max-Heap (depending on the type of Priority queue). The maximum/minimum item in a Heap is always kept in the root, and thus at the front of the queue. Also available are methods to increase priorities and decrease priorities by specific amounts - this doesn't affect the ordering of the items, since all items are affected by the operation. | |
► Sign in to add a comment