ClassPriorityQueue<TValue, TPriority>
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:
[SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
[SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
public sealed class PriorityQueue<TValue, TPriority> : ICollection<TValue>, IEnumerable<TValue>, IEnumerable
Inheritance: objectPriorityQueue<TValue, TPriority>
Implements:
Constructors
PriorityQueue(OrderType)
Initializes a new instance of the PriorityQueue<TValue, TPriority> class.
Declaration
public PriorityQueue(OrderType queueType = OrderType.Descending)
Parameters
queueType
Type of the queue.
PriorityQueue(OrderType, Comparison<TPriority>)
Initializes a new instance of the PriorityQueue<TValue, TPriority> class.
Declaration
public PriorityQueue(OrderType queueType, Comparison<TPriority> comparison)
Parameters
queueType
Type of the queue.
comparison
Comparison<TPriority>
The comparison.
PriorityQueue(OrderType, IComparer<TPriority>)
Initializes a new instance of the PriorityQueue<TValue, TPriority> class.
Properties
Count
Gets the number of elements still in the queue.
DefaultPriority
Gets or sets the default priority when an item is added.
Declaration
public TPriority DefaultPriority { get; set; }
Property Value
TPriority
The default priority.
Remarks
The default value is zero if not set.
IsReadOnly
Gets false since this queue is never read-only.
Methods
Add(TValue)
Adds the specified item to the queue.
Declaration
public void Add(TValue item)
Parameters
item
TValue
The item.
Implements
AddPriorityGroup(IEnumerable<TValue>, TPriority)
Adds the specified items to the priority queue with the specified priority.
Declaration
public void AddPriorityGroup(IEnumerable<TValue> items, TPriority priority)
Parameters
items
IEnumerable<TValue>
The items.
priority
TPriority
The priority.
Exceptions
items is a null reference (Nothing in Visual Basic).
Clear()
Clears this queue of all its items..
Declaration
public void Clear()
Implements
Contains(TValue)
Returns whether the given item is present in the queue.
Declaration
public bool Contains(TValue item)
Parameters
item
TValue
The item.
Returns
true if the queue contains the given item; otherwise, false.
Implements
CopyTo(TValue[], int)
Copies the content of the queue to the given array.
Declaration
public void CopyTo(TValue[] array, int arrayIndex)
Parameters
array
TValue[]
The array.
arrayIndex
Index of the array.
Implements
Dequeue(out TPriority)
Dequeues the item from the head of the queue.
Declaration
[SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters")]
public TValue Dequeue(out TPriority priority)
Parameters
priority
TPriority
The priority of the item to dequeue.
Returns
TValue
The item at the head of the queue.
Exceptions
The PriorityQueue<TValue, TPriority> is empty.
Enqueue(TValue)
Enqueues the specified item.
Declaration
public void Enqueue(TValue item)
Parameters
item
TValue
The item.
Enqueue(TValue, TPriority)
Enqueues the specified item.
Declaration
public void Enqueue(TValue item, TPriority priority)
Parameters
item
TValue
The item.
priority
TPriority
The priority.
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<TValue> GetEnumerator()
Returns
IEnumerator<TValue>
A IEnumerator<T> that can be used to iterate through the collection.
Implements
GetKeyEnumerator()
Returns an enumerator that iterates through the keys in the collection.
Declaration
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public IEnumerator<KeyValuePair<TPriority, TValue>> GetKeyEnumerator()
Returns
IEnumerator<KeyValuePair<TPriority, TValue>>
A IEnumerator<T> that can be used to iterate through the keys in the collection.
GetPriorityGroup(TPriority)
Removes the items with the specified priority.
Declaration
public IList<TValue> GetPriorityGroup(TPriority priority)
Parameters
priority
TPriority
The priority.
Returns
IList<TValue>
The items with the specified priority.
Peek()
Peeks at the item in the front of the queue, without removing it.
Declaration
public TValue Peek()
Returns
TValue
The item at the front of the queue.
Peek(out TPriority)
Peeks at the item in the front of the queue, without removing it.
Declaration
[SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters")]
public TValue Peek(out TPriority priority)
Parameters
priority
TPriority
The priority of the item.
Returns
TValue
The item at the front of the queue.
Pop()
Dequeues the item at the front of the queue.
Declaration
public TValue Pop()
Returns
TValue
The item at the front of the queue.
Push(TValue)
Pushes the specified item in the queue.
Declaration
public void Push(TValue item)
Parameters
item
TValue
The item.
Push(TValue, TPriority)
Adds an item to the ICollection<T>.
Declaration
public void Push(TValue item, TPriority priority)
Parameters
item
TValue
The object to add to the ICollection<T>.
priority
TPriority
The priority of the item.
Remove(TValue)
Removes the specified item from this queue.
Declaration
public bool Remove(TValue item)
Parameters
item
TValue
The item.
Returns
Implements
Remove(TValue, out TPriority)
Removes the first occurrence of the specified item from the property queue.
Declaration
[SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters")]
public bool Remove(TValue item, out TPriority priority)
Parameters
item
TValue
The item to remove.
priority
TPriority
The priority associated with the item.
Returns
true if the item exists in the PriorityQueue<TValue, TPriority> and has been removed; otherwise false.
RemovePriorityGroup(TPriority)
Removes the items with the specified priority.
Declaration
public bool RemovePriorityGroup(TPriority priority)
Parameters
priority
TPriority
The priority.
Returns
true if the priority exists in the PriorityQueue<TValue, TPriority> and has been removed; otherwise false.