Skip to content

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 : unmanaged

Type 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.

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.

Appends an element, throwing when the buffer is full.

public void Add(T value)

Parameters:

value — T

The element to append.

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.

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.

Clears all initialized slots and resets the count to zero.

public void Clear()

Copies all elements into an owned array, then empties the list.

public T[] Drain()

Returns: T[]

The removed elements in their original order.

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.

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.

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.

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.

Copies the initialized elements into an independently owned array.

public T[] ToArray()

Returns: T[]

The elements in list order.

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.

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.

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.

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

Gets whether the list is empty.

public bool IsEmpty { get; }

Value: bool

Gets whether the list has no unused capacity.

public bool IsFull { get; }

Value: bool

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