PgFixedDeque<T>
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Borrows a fixed circular buffer, element count and head index as a double-ended queue.
public readonly ref struct PgFixedDeque<T> where T : unmanagedType parameters:
T
An unmanaged element stored directly in the buffer.
The caller owns and synchronizes all three storage locations. Zero-initialized storage is empty. Views alias their buffers; copying an owning inline-array struct copies the queue.
Constructors
Section titled “Constructors”PgFixedDeque(Span<T>, ref int, ref int)
Section titled “PgFixedDeque(Span<T>, ref int, ref int)”Borrows existing queue storage without changing its contents.
public PgFixedDeque(Span<T> buffer, ref int count, ref int head)Parameters:
buffer — Span<T>
The complete circular element buffer.
count — int
The number of initialized elements.
head — int
The first element’s physical index, or zero for zero-capacity storage.
Properties
Section titled “Properties”Capacity
Section titled “Capacity”Gets the fixed number of elements the queue can hold.
public int Capacity { get; }Value: int
Gets the count, rejecting an uninitialized view or invalid count or head metadata.
public int Count { get; }Value: int
IsEmpty
Section titled “IsEmpty”Gets whether the queue is empty.
public bool IsEmpty { get; }Value: bool
IsFull
Section titled “IsFull”Gets whether the queue has no unused capacity.
public bool IsFull { get; }Value: bool
this[int]
Section titled “this[int]”Gets or replaces an element in logical front-to-back order.
public T this[int index] { get; set; }Parameters:
index — int
The zero-based logical index.
Value: T
Methods
Section titled “Methods”Clear()
Section titled “Clear()”Clears initialized slots and resets the count and head to zero.
public void Clear()CopyTo(Span<T>)
Section titled “CopyTo(Span<T>)”Copies the queue in front-to-back order to nonoverlapping storage.
public void CopyTo(Span<T> destination)Parameters:
destination — Span<T>
Storage with room for at least Count elements.
A short destination or any overlap with the queue buffer is rejected before copying.
Drain()
Section titled “Drain()”Copies all elements into an owned array, then empties the queue.
public T[] Drain()Returns: T[]
The removed elements in front-to-back order.
GetEnumerator()
Section titled “GetEnumerator()”Enumerates elements in front-to-back order without allocating or rearranging the buffer.
public PgFixedDequeEnumerator<T> GetEnumerator()Returns: PgFixedDequeEnumerator<T>
An enumerator invalidated by structural changes to the queue.
GetSpans(out Span<T>, out Span<T>)
Section titled “GetSpans(out Span<T>, out Span<T>)”Borrows the queue’s one or two contiguous segments in front-to-back order.
public void GetSpans(out Span<T> first, out Span<T> second)Parameters:
first — Span<T>
The segment starting at the head.
second — Span<T>
The wrapped segment starting at buffer index zero, possibly empty.
PopBack()
Section titled “PopBack()”Removes and returns the back element, throwing when empty.
public T PopBack()Returns: T
The removed element.
PopFront()
Section titled “PopFront()”Removes and returns the front element, throwing when empty.
public T PopFront()Returns: T
The removed element.
PushBack(T)
Section titled “PushBack(T)”Appends an element at the back, throwing when full.
public void PushBack(T value)Parameters:
value — T
The element to append.
PushFront(T)
Section titled “PushFront(T)”Prepends an element at the front, throwing when full.
public void PushFront(T value)Parameters:
value — T
The element to prepend.
ToArray()
Section titled “ToArray()”Copies the queue into an independently owned array in front-to-back order.
public T[] ToArray()Returns: T[]
The queue’s elements.
TryPopBack(out T)
Section titled “TryPopBack(out T)”Removes the back element if present, clearing its former slot.
public bool TryPopBack(out T value)Parameters:
value — T
The removed element, or default when empty.
Returns: bool
Whether an element was removed.
TryPopFront(out T)
Section titled “TryPopFront(out T)”Removes the front element if present, clearing its former slot.
public bool TryPopFront(out T value)Parameters:
value — T
The removed element, or default when empty.
Returns: bool
Whether an element was removed.
TryPushBack(T)
Section titled “TryPushBack(T)”Appends an element at the back if capacity remains.
public bool TryPushBack(T value)Parameters:
value — T
The element to append.
Returns: bool
False without changes when full.
TryPushFront(T)
Section titled “TryPushFront(T)”Prepends an element at the front if capacity remains.
public bool TryPushFront(T value)Parameters:
value — T
The element to prepend.
Returns: bool
False without changes when full.