Class RandomAccessPriorityQueue<TElement, TPriority>
- Namespace
- Gamelogic.Extensions.Algorithms
- Assembly
- Gamelogic.Extensions.dll
Represents a generic index-based priority queue where elements are ordered based on their priority determined by an IComparer<T>.
[Version(4, 2, 0)]
public sealed class RandomAccessPriorityQueue<TElement, TPriority>
Type Parameters
TElement
The type of elements in the priority queue.
TPriority
The type of the priority of elements in the priority queue.
- Inheritance
-
RandomAccessPriorityQueue<TElement, TPriority>
- Inherited Members
- Extension Methods
Remarks
This implementation of a priority queue uses an array-based binary heap. It associates each value with an index, allowing for efficient updates of the queue based on index. The index should be between 0 (inclusive) and the given capacity (exclusive).
Constructors
- RandomAccessPriorityQueue(int, IComparer<TPriority>)
Initializes a new instance of the IndexPriorityQueue<TElement, TPriority> class with a specified capacity and comparer.
Properties
- Count
Gets the number of elements currently in the priority queue.
- IsEmpty
Gets a value indicating whether the priority queue is empty.
Methods
- Clear()
Clears all elements from the priority queue.
- Contains(int)
Determines whether the priority queue contains the specified index.
- Dequeue()
Removes and returns the minimum element from the priority queue.
- Enqueue(int, TElement, TPriority)
Inserts a value with an associated index into the priority queue.
- Peek()
Returns the minimum element of the priority queue without removing it.
- Remove(int)
Removes the element at the specified index from the priority queue.
- TryDequeue(out (int index, TElement value))
Dequeues the minimum element from the priority queue if it is not empty.
- TryPeek(out (int index, TElement value))
Peeks at the minimum element of the priority queue if it is not empty.
- UpdateValue(int, TElement, TPriority)
Updates the value of the element at the specified index.