Class IndexedPriorityQueue<T>
Generic priority queue data structure, providing random access to its elements
Inheritance
Namespace: Atlas
Assembly: Atlas.Runtime.dll
Syntax
public sealed class IndexedPriorityQueue<T>
where T : IComparable<T>
Type Parameters
Name | Description |
---|---|
T | Type of contained elements |
Constructors
| Improve this Doc View SourceIndexedPriorityQueue()
Constructor
Declaration
public IndexedPriorityQueue()
IndexedPriorityQueue(Int32)
Constructor
Declaration
public IndexedPriorityQueue(int maxSize)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | maxSize | Max number of elements the queue can contain |
Properties
| Improve this Doc View SourceCount
Current number of elements in the queue
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Item[Int32]
Accesses the element at the given index
Declaration
public T this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index of the element to access |
Property Value
Type | Description |
---|---|
T | The value at the given index |
Methods
| Improve this Doc View SourceClear()
Removes all elements from the queue
Declaration
public void Clear()
DecreaseValueAtIndex(Int32, T)
Decreases the value at the current index to the given value
Declaration
public void DecreaseValueAtIndex(int index, T decreasedValue)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index to decrease value of |
T | decreasedValue | New value |
Remarks
This will cause an upward sort of the internal heap
IncreaseValueAtIndex(Int32, T)
Increases the value at the current index to the given value
Declaration
public void IncreaseValueAtIndex(int index, T increasedValue)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index to increase value of |
T | increasedValue | New value |
Remarks
This will cause a downward sort of the internal heap
Insert(Int32, T)
Inserts a new value with the given index
Declaration
public void Insert(int index, T value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | index to insert at |
T | value | value to insert |
Pop()
Removes the top element from the queue
Declaration
public T Pop()
Returns
Type | Description |
---|---|
T | The removed element |
Resize(Int32)
Set the maximum capacity of the queue
Declaration
public void Resize(int maxSize)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | maxSize | The desired maximum capacity |
Set(Int32, T)
Updates the value at the given index. Note that this function is not as efficient as the DecreaseIndex/IncreaseIndex methods, but is best when the value at the index is not known
Declaration
public void Set(int index, T newValue)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index of the value to set |
T | newValue | New value |
Remarks
This will cause either an upward or downard sort of the internal heap
Top()
Gets the top element of the queue
Declaration
public T Top()
Returns
Type | Description |
---|---|
T | The top element |