Class HeapBasedPriorityQueue<T>
Heap-based implementation of a priority queue.
Inheritance
Namespace: Reaqtive.Scheduler
Assembly: Reaqtive.Scheduler.dll
Syntax
public sealed class HeapBasedPriorityQueue<T> : Object
Type Parameters
Name | Description |
---|---|
T | The type of the elements stored in the priority queue. |
Remarks
This type is not thread safe.
Constructors
HeapBasedPriorityQueue(IComparer<T>)
Initializes a new instance of the HeapBasedPriorityQueue<T> class.
Declaration
public HeapBasedPriorityQueue(IComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IComparer<T> | comparer |
HeapBasedPriorityQueue(Int32, IComparer<T>)
Initializes a new instance of the HeapBasedPriorityQueue<T> class.
Declaration
public HeapBasedPriorityQueue(int capacity, IComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | capacity | The capacity. |
System.Collections.Generic.IComparer<T> | comparer | Compared used to compare elements in the queue. |
Properties
Count
Gets the number of elements in the queue.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
Contains(T)
Determines whether the queue contains the specified item
.
Declaration
public bool Contains(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to check for. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Dequeue()
Dequeues the element with the highest priority.
Declaration
public T Dequeue()
Returns
Type | Description |
---|---|
T | The element with the highest priority. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when the queue is empty. |
Enqueue(T)
Enqueues the specified item
in the queue.
Declaration
public void Enqueue(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to enqueue. |
Peek()
Peeks the element with the highest priority.
Declaration
public T Peek()
Returns
Type | Description |
---|---|
T | The element with the highest priority. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when the queue is empty. |
Remove(T)
Removes the specified item
from the queue.
Declaration
public bool Remove(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to remove from the queue. |
Returns
Type | Description |
---|---|
System.Boolean |
|