Class ValueCollectionsMarshal
- Namespace
- Badeend.ValueCollections
- Assembly
- Badeend.ValueCollections.dll
Unsafe utility methods.
public static class ValueCollectionsMarshal
- Inheritance
-
ValueCollectionsMarshal
- Inherited Members
Methods
AsSpan<T>(ValueListBuilder<T>)
Get a Span<T> view over the current data in the
builder
.
Warning
The builder should not be accessed while the span is in
use. Unlike the List<T> equivalent of this method
(CollectionsMarshal.AsSpan
), even just reading from the
builder might trigger undefined behavior.
public static Span<T> AsSpan<T>(ValueListBuilder<T> builder)
Parameters
builder
ValueListBuilder<T>
Returns
- Span<T>
Type Parameters
T
AsValueList<T>(T[])
Create a new ValueList<T> using the provided mutable array as its backing store. This operation only allocates a fixed amount of memory for the new ValueList instance. For the actual content it reuses the provided array instead of copying it over.
Warning
Ownership of the array is moved into the ValueList. It is the caller's responsibility to never mutate the array ever again.
public static ValueList<T> AsValueList<T>(T[] items)
Parameters
items
T[]
Returns
- ValueList<T>
Type Parameters
T
AsValueSlice<T>(T[])
Create a new ValueSlice<T> using the provided mutable array as its backing store. This operation does not allocate any memory.
Warning
Ownership of the array is moved into the ValueSlice. It is the caller's responsibility to never mutate the array ever again.
public static ValueSlice<T> AsValueSlice<T>(T[] items)
Parameters
items
T[]
Returns
- ValueSlice<T>
Type Parameters
T
SetCount<T>(ValueListBuilder<T>, int)
Update the count of the builder
.
Warning
When increasing the count, this may expose uninitialized, garbage data.
public static void SetCount<T>(ValueListBuilder<T> builder, int count)
Parameters
builder
ValueListBuilder<T>count
int
Type Parameters
T