PgFixedList<T>
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Borrows a fixed buffer and its element count as an ordered, bounded list.
public readonly ref struct PgFixedList<T> where T : unmanagedType parameters:
T
An unmanaged element stored directly in the buffer.
The caller owns the buffer and count, and must synchronize access to both. Zero-initialized storage represents an empty list. Copying this view aliases the same storage; copying an owning inline-array struct instead creates independent storage. No operation grows the buffer.
Constructors
Section titled “Constructors”PgFixedList(Span<T>, ref int)
Section titled “PgFixedList(Span<T>, ref int)”Borrows existing list storage without changing its contents.
public PgFixedList(Span<T> buffer, ref int count)Parameters:
buffer — Span<T>
The complete element buffer, including unused capacity.
count — int
The number of initialized elements at the start of the buffer.
Methods
Section titled “Methods”Add(T)
Section titled “Add(T)”Appends an element, throwing when the buffer is full.
public void Add(T value)Parameters:
value — T
The element to append.
AddRange(ReadOnlySpan<T>)
Section titled “AddRange(ReadOnlySpan<T>)”Appends all supplied elements, throwing without changes if they do not fit.
public void AddRange(ReadOnlySpan<T> values)Parameters:
values — ReadOnlySpan<T>
The elements to append.
AsSpan()
Section titled “AsSpan()”Borrows the initialized elements for indexed access or span enumeration.
public Span<T> AsSpan()Returns: Span<T>
A view of the current elements; structural changes invalidate its logical extent.
Clear()
Section titled “Clear()”Clears all initialized slots and resets the count to zero.
public void Clear()Drain()
Section titled “Drain()”Copies all elements into an owned array, then empties the list.
public T[] Drain()Returns: T[]
The removed elements in their original order.
GetEnumerator()
Section titled “GetEnumerator()”Enumerates initialized elements without allocating a snapshot.
public Span<T>.Enumerator GetEnumerator()Returns: Span<T>.Enumerator
An enumerator invalidated by structural changes to the list.
Insert(int, T)
Section titled “Insert(int, T)”Inserts an element at the specified position, shifting subsequent elements right.
public void Insert(int index, T value)Parameters:
index — int
An insertion index from zero through Count.
value — T
The element to insert.
Removes and returns the last element, throwing when empty.
public T Pop()Returns: T
The removed element.
RemoveAt(int)
Section titled “RemoveAt(int)”Removes an element and shifts subsequent elements left, preserving their order.
public T RemoveAt(int index)Parameters:
index — int
The zero-based index to remove.
Returns: T
The removed element.
SwapRemoveAt(int)
Section titled “SwapRemoveAt(int)”Removes an element by moving the last element into its position.
public T SwapRemoveAt(int index)Parameters:
index — int
The zero-based index to remove.
Returns: T
The removed element. The remaining order can change.
ToArray()
Section titled “ToArray()”Copies the initialized elements into an independently owned array.
public T[] ToArray()Returns: T[]
The elements in list order.
TryAdd(T)
Section titled “TryAdd(T)”Appends an element, returning false without changes when the buffer is full.
public bool TryAdd(T value)Parameters:
value — T
The element to append.
Returns: bool
Whether the element was appended.
TryAddRange(ReadOnlySpan<T>)
Section titled “TryAddRange(ReadOnlySpan<T>)”Appends all supplied elements, including overlapping source storage, if they fit.
public bool TryAddRange(ReadOnlySpan<T> values)Parameters:
values — ReadOnlySpan<T>
The elements to append.
Returns: bool
False without changes when there is insufficient remaining capacity.
TryPop(out T)
Section titled “TryPop(out T)”Removes the last element if present and clears its former slot.
public bool TryPop(out T value)Parameters:
value — T
The removed element, or default when empty.
Returns: bool
Whether an element was removed.
Properties
Section titled “Properties”Capacity
Section titled “Capacity”Gets the fixed number of elements the buffer can hold.
public int Capacity { get; }Value: int
Gets the current element count, rejecting an uninitialized view or invalid metadata.
public int Count { get; }Value: int
IsEmpty
Section titled “IsEmpty”Gets whether the list is empty.
public bool IsEmpty { get; }Value: bool
IsFull
Section titled “IsFull”Gets whether the list has no unused capacity.
public bool IsFull { get; }Value: bool
this[int]
Section titled “this[int]”Gets or replaces an existing element without changing the count.
public T this[int index] { get; set; }Parameters:
index — int
The zero-based element index.
Value: T