Priority queue implementation based on a RedBlackTreeList<TKey, TValue>.
Definition
Namespace:Telerik.Windows.Diagrams.Core
Assembly:Telerik.Windows.Diagrams.Core.dll
Type Parameters:
TValue
The data type of the value.
TPriority
The data type of the priority indicator.
Syntax:
public sealed class PriorityQueue<TValue, TPriority> : ICollection<TValue>, IEnumerable<TValue>, IEnumerable
Inheritance: objectPriorityQueue<TValue, TPriority>
Implements:
Constructors
Initializes a new instance of the PriorityQueue<TValue, TPriority> class.
public PriorityQueue(OrderType queueType, Comparison<TPriority> comparison)
Type of the queue.
comparisonComparison<TPriority>The comparison.
Initializes a new instance of the PriorityQueue<TValue, TPriority> class.
Initializes a new instance of the PriorityQueue<TValue, TPriority> class.
public PriorityQueue(OrderType queueType = OrderType.Descending)
Type of the queue.
Properties
DefaultPriority
TPriority
Gets or sets the default priority when an item is added.
public TPriority DefaultPriority { get; set; }
The default priority.
The default value is zero if not set.
Gets false since this queue is never read-only.
public bool IsReadOnly { get; }
false.
Implements:
Methods
Adds the specified item to the queue.
public void Add(TValue item)
The item.
Implements:
Adds the specified items to the priority queue with the specified priority.
public void AddPriorityGroup(IEnumerable<TValue> items, TPriority priority)
The items.
priorityTPriorityThe priority.
Exceptions:items is a null reference (Nothing in Visual Basic).
Clears this queue of all its items..
public void Clear()
Implements:
Returns whether the given item is present in the queue.
public bool Contains(TValue item)
The item.
Returns:true if the queue contains the given item; otherwise, false.
Implements:
Copies the content of the queue to the given array.
public void CopyTo(TValue[] array, int arrayIndex)
The array.
arrayIndexintIndex of the array.
Implements:
Dequeues the item from the head of the queue.
public TValue Dequeue(out TPriority priority)
The priority of the item to dequeue.
Returns:TValue
The item at the head of the queue.
Exceptions:The PriorityQueue<TValue, TPriority> is empty.
Enqueues the specified item.
public void Enqueue(TValue item, TPriority priority)
The item.
priorityTPriorityThe priority.
Enqueues the specified item.
public void Enqueue(TValue item)
The item.
Returns an enumerator that iterates through the collection.
public IEnumerator<TValue> GetEnumerator()
IEnumerator<TValue>
A IEnumerator<T> that can be used to iterate through the collection.
Implements:
Returns an enumerator that iterates through the keys in the collection.
public IEnumerator<KeyValuePair<TPriority, TValue>> GetKeyEnumerator()
IEnumerator<KeyValuePair<TPriority, TValue>>
A IEnumerator<T> that can be used to iterate through the keys in the collection.
Removes the items with the specified priority.
public IList<TValue> GetPriorityGroup(TPriority priority)
The priority.
Returns:IList<TValue>
The items with the specified priority.
Peeks at the item in the front of the queue, without removing it.
public TValue Peek()
TValue
The item at the front of the queue.
Peeks at the item in the front of the queue, without removing it.
public TValue Peek(out TPriority priority)
The priority of the item.
Returns:TValue
The item at the front of the queue.
Dequeues the item at the front of the queue.
public TValue Pop()
TValue
The item at the front of the queue.
Adds an item to the ICollection<T>.
public void Push(TValue item, TPriority priority)
The object to add to the ICollection<T>.
priorityTPriorityThe priority of the item.
Pushes the specified item in the queue.
public void Push(TValue item)
The item.
Removes the first occurrence of the specified item from the property queue.
public bool Remove(TValue item, out TPriority priority)
The item to remove.
priorityTPriorityThe priority associated with the item.
Returns:true if the item exists in the PriorityQueue<TValue, TPriority> and has been removed; otherwise false.
Removes the specified item from this queue.
Removes the items with the specified priority.
public bool RemovePriorityGroup(TPriority priority)
The priority.
Returns:true if the priority exists in the PriorityQueue<TValue, TPriority> and has been removed; otherwise false.