MeatMotion

FastListCore<T>

Array-backed list with a separate element count. AsSpan covers the live range and AsArray exposes the backing array.

Namespace
MeatMotion.Collections
Assembly
MeatMotion

Jump to members

public struct FastListCore<T>
MotionCollections.cs · L7

Members

Empty

Default list with no entries.

public static readonly FastListCore<T> Empty;

Length

Number of live entries in the backing array.

public readonly int Length { get; }

this

Read or replace an indexed slot. Use an index below Length.

public readonly T this[int index] { get; set; }

AsSpan

Return a span covering only live entries.

public readonly Span<T> AsSpan()
Return value
Returns
Span<T>

AsArray

Return the backing array including unused capacity.

public readonly T[] AsArray()
Return value
Returns
T[]

EnsureCapacity

Reserve backing space for at least the requested number of elements.

public void EnsureCapacity(int capacity)
Parameters
capacity
int Number of entries to reserve.

Add

Append an element, growing the backing array when needed.

public void Add(T element)
Parameters
element
T Element to append.

RemoveAtSwapback

Remove an entry by moving the last element into its slot, which changes ordering.

public void RemoveAtSwapback(int index)
Parameters
index
int Index of the entry to operate on.

Clear

Clear the entries and reset the count. Set removeArray to also release the backing array.

public void Clear(bool removeArray = false)
Parameters
removeArray = false
bool Also release the backing array when true.