PriorityQueue<TElement,TPriority> 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 <typename TElement, typename TPriority>
public ref class PriorityQueue
public class PriorityQueue<TElement,TPriority>
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<TElement,TPriority>
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
PriorityQueue<TElement,TPriority>() |
Initializes a new instance of the PriorityQueue<TElement,TPriority> class. |
PriorityQueue<TElement,TPriority>(IComparer<TPriority>) |
Initializes a new instance of the PriorityQueue<TElement,TPriority> class with the specified custom priority comparer. |
PriorityQueue<TElement,TPriority>(IEnumerable<ValueTuple<TElement,TPriority>>) |
Initializes a new instance of the PriorityQueue<TElement,TPriority> class that is populated with the specified elements and priorities. |
PriorityQueue<TElement,TPriority>(IEnumerable<ValueTuple<TElement,TPriority>>, IComparer<TPriority>) |
Initializes a new instance of the PriorityQueue<TElement,TPriority> class that is populated with the specified elements and priorities, and with the specified custom priority comparer. |
PriorityQueue<TElement,TPriority>(Int32) |
Initializes a new instance of the PriorityQueue<TElement,TPriority> class with the specified initial capacity. |
PriorityQueue<TElement,TPriority>(Int32, IComparer<TPriority>) |
Initializes a new instance of the PriorityQueue<TElement,TPriority> class with the specified initial capacity and custom priority comparer. |
Properties
Comparer |
Gets the priority comparer used by the PriorityQueue<TElement,TPriority>. |
Count |
Gets the number of elements contained in the PriorityQueue<TElement,TPriority>. |
UnorderedItems |
Gets a collection that enumerates the elements of the queue in an unordered manner. |
Methods
Clear() |
Removes all items from the PriorityQueue<TElement,TPriority>. |
Dequeue() |
Removes and returns the minimal element from the PriorityQueue<TElement,TPriority> - that is, the element with the lowest priority value. |
DequeueEnqueue(TElement, TPriority) |
Removes the minimal element and then immediately adds the specified element with associated priority to the PriorityQueue<TElement,TPriority>. |
Enqueue(TElement, TPriority) |
Adds the specified element with associated priority to the PriorityQueue<TElement,TPriority>. |
EnqueueDequeue(TElement, TPriority) |
Adds the specified element with associated priority to the PriorityQueue<TElement,TPriority>, and immediately removes the minimal element, returning the result. |
EnqueueRange(IEnumerable<TElement>, TPriority) |
Enqueues a sequence of elements pairs to the PriorityQueue<TElement,TPriority>, all associated with the specified priority. |
EnqueueRange(IEnumerable<ValueTuple<TElement,TPriority>>) |
Enqueues a sequence of element-priority pairs to the PriorityQueue<TElement,TPriority>. |
EnsureCapacity(Int32) |
Ensures that the PriorityQueue<TElement,TPriority> can hold up to |
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<TElement,TPriority> without removing it. |
Remove(TElement, TElement, TPriority, IEqualityComparer<TElement>) |
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<TElement,TPriority>, if that is less than 90 percent of current capacity. |
TryDequeue(TElement, TPriority) |
Removes the minimal element from the PriorityQueue<TElement,TPriority>, and copies it and its associated priority to the |
TryPeek(TElement, TPriority) |
Returns a value that indicates whether there is a minimal element in the PriorityQueue<TElement,TPriority>, and if one is present, copies it and its associated priority to the |
Applies to
Feedback
https://aka.ms/ContentUserFeedback.
Binnenkort: Gedurende 2024 worden GitHub Issues uitgefaseerd als het feedbackmechanisme voor inhoud. Dit wordt vervangen door een nieuw feedbacksysteem. Ga voor meer informatie naar:Feedback verzenden en bekijken voor