Interface IPeekKthPriorityQueue<T>
An IPriorityQueue<T> which supports efficient peek of the item stored in the queue with the k-highest priority.
Inherited Members
Namespace: MoreStructures.PriorityQueues
Assembly: MoreStructures.dll
Syntax
public interface IPeekKthPriorityQueue<T> : IPriorityQueue<T>
Type Parameters
Name | Description |
---|---|
T |
Remarks
PeekKth(Int32) can be implemented in a general way by copying the entire data structure and then
performing k Pop(), followed by a single Peek().
This approach is however expensive both in time and space, having O(n) Time and Space Complexity for all known
implementation of IPriorityQueue<T>..
Implementing this interface can take advantage of the properties of the underlying data structure implementing the
priority queue, and providing better-than-linear performance.
Methods
| Improve this Doc View SourcePeekKth(Int32)
Retrieves the item of the queue with priority k
, without extracting any of the items in the
queue.
Declaration
PrioritizedItem<T>? PeekKth(int k)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | k | The non-negative priority rank: 0 means highest priority, 1 second highest, etc. |
Returns
Type | Description |
---|---|
System.Nullable<MoreStructures.PriorityQueues.PrioritizedItem<T>> | The MoreStructures.PriorityQueues.PrioritizedItem<T> with k-th highest priority if any. Null otherwise. |
Remarks
PeekKth(Int32) with k == 0
is equivalent to Peek().