Skip to main content

FastPriorityQueueTimeSpan<T>

A class in Alta.Timing.Runtime, Alta.Timing.PriorityQueue.

Copy of FastPriorityQueue that uses a TimeSpan priority, earliest first. Timeline uses it to order its scheduled calls.

Constructors​

MemberWhat it is
FastPriorityQueueTimeSpan(int maxNodes)Creates a FastPriorityQueueTimeSpan from maxNodes.

Fields​

2 private and internal fields
MemberWhat it is
private T[] _nodesHeap array. Slot 0 is unused.
private int _numNodesBacking field for Count.

Properties​

MemberWhat it is
int Count { get; }Number of nodes in the queue.
T First { get; }The earliest node, without removing it.
int MaxSize { get; }How many nodes the queue can hold.

Methods​

MemberWhat it is
void Clear()Empties the queue without resizing it.
bool Contains(T node)True if the node is in this queue, checked through its stored index.
T Dequeue()Removes and returns the earliest node. Does not check for an empty queue.
void Enqueue(T node, TimeSpan priority)Adds a node with a time. Does not check for a full queue or a node already queued.
IEnumerator<T> GetEnumerator() (iterator)Enumerates nodes in heap order, not time order.
bool IsValidQueue()Debug check that every parent comes before its children.
void Remove(T node)Removes a node from anywhere in the queue.
void Resize(int maxNodes)Changes the capacity, dropping nodes beyond the new size.
void UpdatePriority(T node, TimeSpan priority)Changes a queued node's time and moves it to its new place.
6 private and internal methods
MemberWhat it is
private void CascadeDown(T node)Moves a node down the heap until both children are later.
private void CascadeUp(T node)Moves a node up the heap past later parents.
private IEnumerator System.Collections.IEnumerable.GetEnumerator()Enumerates nodes in heap order, not time order.
private bool HasHigherOrEqualPriority(T higher, T lower)True if the first node's time is earlier or equal.
private bool HasHigherPriority(T higher, T lower)True if the first node's time is strictly earlier.
private void OnNodeUpdated(T node)Moves a node up or down after its time changed.

Used in​

Members of other types that take, return or hold a FastPriorityQueueTimeSpan&lt;T>: