My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for

Contents

Complete wiki list

PriorityQueue  
The Priority Queue data structure
Updated Aug 12, 2009 by hus...@gmail.com

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.

More Information on Priority Queues


Sign in to add a comment
Powered by Google Project Hosting