Class PriorityQueue<TValue, TPriority>
Priority queue implementation based on a Telerik.Windows.Diagrams.Core.RedBlackTreeList`2.
Inheritance
Inherited Members
Namespace: Telerik.Windows.Diagrams.Core
Assembly: Telerik.Windows.Diagrams.Core.dll
Syntax
public sealed class PriorityQueue<TValue, TPriority> : ICollection<TValue>, IEnumerable<TValue>, IEnumerable
Type Parameters
TValue
The data type of the value. |
TPriority
The data type of the priority indicator. |
Remarks
Constructors
PriorityQueue(OrderType)
Initializes a new instance of the PriorityQueue<TValue, TPriority> class.
Declaration
public PriorityQueue(OrderType queueType = OrderType.Descending)
Parameters
OrderType
queueType
Type of the queue. |
PriorityQueue(OrderType, IComparer<TPriority>)
Initializes a new instance of the PriorityQueue<TValue, TPriority> class.
Declaration
public PriorityQueue(OrderType queueType, IComparer<TPriority> comparer)
Parameters
OrderType
queueType
Type of the queue. |
System.Collections.Generic.IComparer<TPriority>
comparer
The comparer. |
PriorityQueue(OrderType, Comparison<TPriority>)
Initializes a new instance of the PriorityQueue<TValue, TPriority> class.
Declaration
public PriorityQueue(OrderType queueType, Comparison<TPriority> comparison)
Parameters
OrderType
queueType
Type of the queue. |
System.Comparison<TPriority>
comparison
The comparison. |
Properties
Count
Gets the number of elements still in the queue.
Declaration
public int Count { get; }
Property Value
System.Int32
|
Implements
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.
Declaration
public bool IsReadOnly { get; }
Property Value
System.Boolean
|
Implements
Methods
Add(TValue)
Adds the specified item to the queue.
Declaration
public void Add(TValue item)
Parameters
TValue
item
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
System.Collections.Generic.IEnumerable<TValue>
items
The items. |
TPriority
priority
The priority. |
Exceptions
System.ArgumentNullException
|
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
TValue
item
The item. |
Returns
System.Boolean
|
Implements
CopyTo(TValue[], Int32)
Copies the content of the queue to the given array.
Declaration
public void CopyTo(TValue[] array, int arrayIndex)
Parameters
TValue[]
array
The array. |
System.Int32
arrayIndex
Index of the array. |
Implements
Dequeue(out TPriority)
Dequeues the item from the head of the queue.
Declaration
public TValue Dequeue(out TPriority priority)
Parameters
TPriority
priority
The priority of the item to dequeue. |
Returns
TValue
The item at the head of the queue. |
Exceptions
System.InvalidOperationException
The PriorityQueue<TValue, TPriority> is empty. |
Enqueue(TValue)
Enqueues the specified item.
Declaration
public void Enqueue(TValue item)
Parameters
TValue
item
The item. |
Enqueue(TValue, TPriority)
Enqueues the specified item.
Declaration
public void Enqueue(TValue item, TPriority priority)
Parameters
TValue
item
The item. |
TPriority
priority
The priority. |
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<TValue> GetEnumerator()
Returns
System.Collections.Generic.IEnumerator<TValue>
A System.Collections.Generic.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
public IEnumerator<KeyValuePair<TPriority, TValue>> GetKeyEnumerator()
Returns
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<TPriority, TValue>>
A System.Collections.Generic.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
TPriority
priority
The priority. |
Returns
System.Collections.Generic.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
public TValue Peek(out TPriority priority)
Parameters
TPriority
priority
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. |
See Also
Push(TValue)
Pushes the specified item in the queue.
Declaration
public void Push(TValue item)
Parameters
TValue
item
The item. |
Push(TValue, TPriority)
Adds an item to the System.Collections.Generic.ICollection<T>.
Declaration
public void Push(TValue item, TPriority priority)
Parameters
TValue
item
The object to add to the System.Collections.Generic.ICollection<T>. |
TPriority
priority
The priority of the item. |
Remove(TValue)
Removes the specified item from this queue.
Declaration
public bool Remove(TValue item)
Parameters
TValue
item
The item. |
Returns
System.Boolean
|
Implements
Remove(TValue, out TPriority)
Removes the first occurrence of the specified item from the property queue.
Declaration
public bool Remove(TValue item, out TPriority priority)
Parameters
TValue
item
The item to remove. |
TPriority
priority
The priority associated with the item. |
Returns
System.Boolean
|
RemovePriorityGroup(TPriority)
Removes the items with the specified priority.
Declaration
public bool RemovePriorityGroup(TPriority priority)
Parameters
TPriority
priority
The priority. |
Returns
System.Boolean
|
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Returns an enumerator that iterates through a collection.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
System.Collections.IEnumerator
An System.Collections.IEnumerator object that can be used to iterate through the collection. |