Interface IPriorityQueue<T>
Defines the interface common to all Priority Queue implementations.
Namespace: MoreStructures.PriorityQueues
Assembly: MoreStructures.dll
Syntax
public interface IPriorityQueue<T>
Type Parameters
Name | Description |
---|---|
T | The type of items, the queue is composed of. |
Remarks
DEFINITION
- A Priority Queue is a data structure storing items of a generic type T
, together with
their priority.
- Duplicates, both for items and their priorities, are supported.
- Priorities are defined as System.Int32 values: the bigger the value, the higher is the priority of the
item.
- The core operations of any Priority Queue are insertion of an item with related priority,
extraction of the item with the highest priority and testing for empty.
- Other operations are provided, such as total count of items and peeking (retrieval without
extraction).
- More advanced operations, requiring auxiliary data structures for their implementation, are not specified
by this interface: examples are priority update and removal of an item.
- Popular implementations make both insertion and extraction sub-linear operations (i.e. faster than O(n)).
Properties
| Improve this Doc View SourceCount
The number of items currently in the queue.
Declaration
int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 | A non-negative value. |
Methods
| Improve this Doc View SourcePeek()
Retrieves the item of the queue with highest priority, without extracting it.
Declaration
PrioritizedItem<T> Peek()
Returns
Type | Description |
---|---|
MoreStructures.PriorityQueues.PrioritizedItem<T> | A MoreStructures.PriorityQueues.PrioritizedItem<T> wrapping the item with the highest priority, together with its priority and push timestamp. |
Remarks
Check Pop() for retrieval and extraction of the item.
Pop()
Extracts the item of the queue with highest priority.
Declaration
PrioritizedItem<T> Pop()
Returns
Type | Description |
---|---|
MoreStructures.PriorityQueues.PrioritizedItem<T> | A MoreStructures.PriorityQueues.PrioritizedItem<T> wrapping the item with the highest priority, together with its priority and push timestamp. |
Remarks
Check Pop() for retrieval without extraction of the item.
Push(T, Int32)
Inserts the provided item
into the queue, with the provided priority
.
Declaration
void Push(T item, int priority)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to be inserted into the queue. |
System.Int32 | priority | The priority to be assigned to the |