PriorityQueue Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a collection of items that have a value and a priority. On dequeue, the item with the lowest priority value is removed.
generic
public ref class PriorityQueue
public class PriorityQueue
type PriorityQueue<'Element, 'Priority> = class
Public Class PriorityQueue(Of TElement, TPriority)
Type Parameters
- TElement
Specifies the type of elements in the queue.
- TPriority
Specifies the type of priority associated with enqueued elements.
- Inheritance
-
PriorityQueue
Remarks
Implements an array-backed, quaternary min-heap. Each element is enqueued with an associated priority that determines the dequeue order. Elements with the lowest priority are dequeued first. Note that the type does not guarantee first-in-first-out semantics for elements of equal priority.
Constructors
| Name | Description |
|---|---|
|
PriorityQueue |
Initializes a new instance of the PriorityQueue |
|
PriorityQueue |
Initializes a new instance of the PriorityQueue |
|
PriorityQueue |
Initializes a new instance of the PriorityQueue |
|
PriorityQueue |
Initializes a new instance of the PriorityQueue |
|
PriorityQueue |
Initializes a new instance of the PriorityQueue |
|
PriorityQueue |
Initializes a new instance of the PriorityQueue |
Properties
| Name | Description |
|---|---|
| Capacity |
Gets the total numbers of elements the queue's backing storage can hold without resizing. |
| Comparer |
Gets the priority comparer used by the PriorityQueue |
| Count |
Gets the number of elements contained in the PriorityQueue |
| UnorderedItems |
Gets a collection that enumerates the elements of the queue in an unordered manner. |
Methods
| Name | Description |
|---|---|
| Clear() |
Removes all items from the PriorityQueue |
| Dequeue() |
Removes and returns the minimal element from the PriorityQueue |
| DequeueEnqueue(TElement, TPriority) |
Removes the minimal element and then immediately adds the specified element with associated priority to the PriorityQueue |
| Enqueue(TElement, TPriority) |
Adds the specified element with associated priority to the PriorityQueue |
| EnqueueDequeue(TElement, TPriority) |
Adds the specified element with associated priority to the PriorityQueue |
|
EnqueueRange(IEnumerable |
Enqueues a sequence of elements pairs to the PriorityQueue |
|
EnqueueRange(IEnumerable |
Enqueues a sequence of element-priority pairs to the PriorityQueue |
| EnsureCapacity(Int32) |
Ensures that the PriorityQueue |
| Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
| GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
| GetType() |
Gets the Type of the current instance. (Inherited from Object) |
| MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
| Peek() |
Returns the minimal element from the PriorityQueue |
|
Remove(TElement, TElement, TPriority, IEqualityComparer |
Removes the first occurrence that equals the specified parameter. |
| ToString() |
Returns a string that represents the current object. (Inherited from Object) |
| TrimExcess() |
Sets the capacity to the actual number of items in the PriorityQueue |
| TryDequeue(TElement, TPriority) |
Removes the minimal element from the PriorityQueue |
| TryPeek(TElement, TPriority) |
Returns a value that indicates whether there is a minimal element in the PriorityQueue |