Class AlternativePriorityQueue<TPriority, TData>
An alternative implementation of the priority queue abstract data type. This allows us to do more than PriorityQueue<T>, which we got from JTS. Ultimately, this queue enables scenarios that have more favorable execution speed characteristics at the cost of less favorable memory and usability characteristics.
Inherited Members
Namespace: NetTopologySuite.Utilities
Assembly: NetTopologySuite.dll
Syntax
public sealed class AlternativePriorityQueue<TPriority, TData> : IEnumerable<PriorityQueueNode<TPriority, TData>>, IEnumerable
Type Parameters
Name | Description |
---|---|
TPriority | The type of the priority for each queue node. |
TData | The type of data stored in the queue. |
Remarks
When enumerating over the queue, note that the elements will not be in sorted order. To get at the elements in sorted order, use the copy constructor and repeatedly Dequeue() elements from it.
Constructors
| Improve this Doc View SourceAlternativePriorityQueue()
Initializes a new instance of the AlternativePriorityQueue<TPriority, TData> class.
Declaration
public AlternativePriorityQueue()
AlternativePriorityQueue(AlternativePriorityQueue<TPriority, TData>)
Initializes a new instance of the AlternativePriorityQueue<TPriority, TData> class.
Declaration
public AlternativePriorityQueue(AlternativePriorityQueue<TPriority, TData> copyFrom)
Parameters
Type | Name | Description |
---|---|---|
AlternativePriorityQueue<TPriority, TData> | copyFrom | The AlternativePriorityQueue<TPriority, TData> to copy from. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
AlternativePriorityQueue(IComparer<TPriority>)
Initializes a new instance of the AlternativePriorityQueue<TPriority, TData> class.
Declaration
public AlternativePriorityQueue(IComparer<TPriority> priorityComparer)
Parameters
Type | Name | Description |
---|---|---|
IComparer<TPriority> | priorityComparer | The IComparer<T> to use to compare priority values, or null to use the default comparer for the type. |
AlternativePriorityQueue(Int32)
Initializes a new instance of the AlternativePriorityQueue<TPriority, TData> class.
Declaration
public AlternativePriorityQueue(int capacity)
Parameters
Type | Name | Description |
---|---|---|
Int32 | capacity | The initial queue capacity. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
AlternativePriorityQueue(Int32, IComparer<TPriority>)
Initializes a new instance of the AlternativePriorityQueue<TPriority, TData> class.
Declaration
public AlternativePriorityQueue(int capacity, IComparer<TPriority> priorityComparer)
Parameters
Type | Name | Description |
---|---|---|
Int32 | capacity | The initial queue capacity. |
IComparer<TPriority> | priorityComparer | The IComparer<T> to use to compare priority values, or null to use the default comparer for the type. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
Properties
| Improve this Doc View SourceCount
Gets the number of nodes currently stored in this queue.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 |
Head
Gets the node at the head of the queue.
This is the node whose TPriority
compares
less than or equal to the priority of all other nodes in the queue.
Declaration
public PriorityQueueNode<TPriority, TData> Head { get; }
Property Value
Type | Description |
---|---|
PriorityQueueNode<TPriority, TData> |
Methods
| Improve this Doc View SourceChangePriority(PriorityQueueNode<TPriority, TData>, TPriority)
Changes the priority of the given node.
Declaration
public void ChangePriority(PriorityQueueNode<TPriority, TData> node, TPriority priority)
Parameters
Type | Name | Description |
---|---|---|
PriorityQueueNode<TPriority, TData> | node | The node whose priority to change. |
TPriority | priority | The new priority for the node. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Clear()
Removes all nodes from this queue.
Declaration
public void Clear()
Contains(PriorityQueueNode<TPriority, TData>)
Determines whether the given node is contained within this queue.
Declaration
public bool Contains(PriorityQueueNode<TPriority, TData> node)
Parameters
Type | Name | Description |
---|---|---|
PriorityQueueNode<TPriority, TData> | node | The node to locate in the queue. |
Returns
Type | Description |
---|---|
Boolean | true if |
Dequeue()
Removes and returns the head of the queue.
Declaration
public PriorityQueueNode<TPriority, TData> Dequeue()
Returns
Type | Description |
---|---|
PriorityQueueNode<TPriority, TData> | The removed element. |
Enqueue(PriorityQueueNode<TPriority, TData>, TPriority)
Adds a given node to the queue with the given priority.
Declaration
public void Enqueue(PriorityQueueNode<TPriority, TData> node, TPriority priority)
Parameters
Type | Name | Description |
---|---|---|
PriorityQueueNode<TPriority, TData> | node | The node to add to the queue. |
TPriority | priority | The priority for the node. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GetEnumerator()
Declaration
public IEnumerator<PriorityQueueNode<TPriority, TData>> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<PriorityQueueNode<TPriority, TData>> |
Remove(PriorityQueueNode<TPriority, TData>)
Removes the given node from this queue if it is present.
Declaration
public bool Remove(PriorityQueueNode<TPriority, TData> node)
Parameters
Type | Name | Description |
---|---|---|
PriorityQueueNode<TPriority, TData> | node | The node to remove if present. |
Returns
Type | Description |
---|---|
Boolean | A value indicating whether the node was removed. |
Explicit Interface Implementations
| Improve this Doc View SourceIEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator |