Struct ComponentCollectionAccessor<T>
Mutable accessor for a collection-typed component field — the variable-sized element list backing a ComponentCollection<T> value. Appends
reach the owning field by ref, transparently performing copy-on-write when the buffer is shared across MVCC revisions. Must be disposed; disposal
commits the pending buffer writes.
public ref struct ComponentCollectionAccessor<T> : IDisposable where T : unmanaged
Type Parameters
TUnmanaged element type of the collection.
- Implements
- Inherited Members
Constructors
ComponentCollectionAccessor(ChangeSet, VariableSizedBufferSegment<T, PersistentStore>, ref ComponentCollection<T>)
Binds an accessor to collection field field and its backing buffer segment, capturing a chunk accessor from changeSet.
public ComponentCollectionAccessor(ChangeSet changeSet, VariableSizedBufferSegment<T, PersistentStore> vsbs, ref ComponentCollection<T> field)
Parameters
changeSetChangeSetChange set the buffer mutations are threaded through (dirty tracking and commit).
vsbsVariableSizedBufferSegment<T, PersistentStore>Backing variable-sized buffer segment that stores the collection's elements.
fieldComponentCollection<T>Reference to the collection field being accessed; Add(T) updates its buffer id in place.
Properties
ElementCount
Total number of elements currently in the collection.
public int ElementCount { get; }
Property Value
Methods
Add(T)
Appends value to the collection, allocating the backing buffer on first use. Under Versioned storage, a
buffer shared with another revision (copy-on-write) is cloned before mutation; a solely-owned buffer is appended in place.
public void Add(T value)
Parameters
valueTElement to append.
Dispose()
Commits the pending buffer writes and releases the underlying chunk accessor.
public void Dispose()
GetAllElements()
Allocates and returns a new array containing every element of the collection.
public T[] GetAllElements()
Returns
- T[]
A newly allocated array of length ElementCount.
GetAllElements(Span<T>)
Copies every element into dest.
public int GetAllElements(Span<T> dest)
Parameters
destSpan<T>Destination span; must be at least ElementCount elements long.
Returns
- int
The number of elements copied, or
0whendestis too small (in which case nothing is copied).