public sealed class ChunkedArray<T>A growable array built from fixed-size chunks, so that a reference into it stays valid when it grows.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
The property a List<T> cannot offer: growing it reallocates and every outstanding ref points at the old array. Anything that hands out references into its storage and also grows — an ECS chunk store, a node pool, an interned table — needs this instead.
The cost is that the elements are not contiguous, so there is no whole-collection Span. Iterate chunk by chunk with GetChunk; each chunk is contiguous, and that is the granularity a vectorised sweep wants anyway.
Fields and properties (4)
public int CountHow many elements the array holds.
public int ChunkSizeHow many elements each chunk holds. Always a power of two.
public int ChunkCountHow many chunks currently exist.
public ref T this[int index]A reference to the element at .
Methods (7)
public ChunkedArray(int chunkSize = 1024)Creates an array with the given chunk size.
public int Add(T item)Appends an element.
public void Grow(int count)Grows the array to elements, defaulting the new ones.
public Span<T> GetChunk(int chunkIndex)One chunk's worth of elements, contiguous.
public void Clear()Empties the array. Keeps the chunks allocated for reuse.
public void Reset()Drops every chunk, releasing the memory.
public ChunkedArray<T>.Enumerator GetEnumerator()Enumerates the elements in index order.
Used by (3)
- CollectionTestsVixen.Core.Collections.Tests
- EnumeratorVixen.Core.Collections
- ManagedComponentStoreVixen.Ecs