Class HeapArray<T, TCompare>
A heap with static priorities implemented as a array.
Inheritance
Implements
Namespace: Towel.DataStructures
Assembly: Towel.dll
Syntax
public class HeapArray<T, TCompare> : object, IHeap<T, TCompare>, DataStructure.IComparing<T, TCompare>, IHeap<T>, IDataStructure<T>, ISteppable<T>, System.Collections.Generic.IEnumerable<T>, DataStructure.ICountable, DataStructure.IClearable, ICloneable<HeapArray<T, TCompare>> where TCompare : struct, IFunc<T, T, CompareResult>
Type Parameters
Name | Description |
---|---|
T | The type of values stored in this data structure. |
TCompare | The type that is comparing |
Constructors
| Improve this Doc View SourceHeapArray(TCompare, Nullable<Int32>)
Declaration
public HeapArray(TCompare compare = default(TCompare), int? minimumCapacity = null)
Parameters
Type | Name | Description |
---|---|---|
TCompare | compare | |
System.Nullable<System.Int32> | minimumCapacity |
Properties
| Improve this Doc View SourceCompare
Gets the value of the comparer that is comparing T
values.
Declaration
public TCompare Compare { get; }
Property Value
Type | Description |
---|---|
TCompare |
Count
Gets the current count of the data structure.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
CurrentCapacity
The maximum items the queue can hold.
Runtime: O(1)
Declaration
public int CurrentCapacity { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
MinimumCapacity
The minumum capacity of this queue to limit low-level resizing.
Runtime: O(1)
Declaration
public int? MinimumCapacity { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Int32> |
Methods
| Improve this Doc View SourceClear()
Returns the data structure to an empty state.
Declaration
public void Clear()
Clone()
Clones a T
.
Declaration
public HeapArray<T, TCompare> Clone()
Returns
Type | Description |
---|---|
HeapArray<T, TCompare> | A clone of the |
Dequeue()
Removes and returns the highest priority item.
Declaration
public T Dequeue()
Returns
Type | Description |
---|---|
T | The highest priority item from the heap. |
Enqueue(T)
Enqueues an item into the heap.
Declaration
public void Enqueue(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to queue in the heap. |
GetEnumerator()
Declaration
public System.Collections.Generic.IEnumerator<T> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<T> |
Peek()
Returns the highest priority item.
Declaration
public T Peek()
Returns
Type | Description |
---|---|
T | The highest priority item in the heap. |
Requeue(T)
Requeues an item after a change has occured.
Runtime: O(n)
Declaration
public void Requeue(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to requeue. |
StepperBreak<TStep>(TStep)
Traverses values and invokes a function on every T
value.
Declaration
public StepStatus StepperBreak<TStep>(TStep step = default(TStep))
where TStep : struct, IFunc<T, StepStatus>
Parameters
Type | Name | Description |
---|---|---|
TStep | step | The function to invoke on every |
Returns
Type | Description |
---|---|
StepStatus | The status of the traversal. |
Type Parameters
Name | Description |
---|---|
TStep | The type of function to invoke on every |
ToArray()
Constructs an array with the values of this data structure.
Declaration
public T[] ToArray()
Returns
Type | Description |
---|---|
T[] | An array with the values of this data structure. |