Class PrimitiveArray<T>
- Namespace
- CStructSharp.Values
- Assembly
- CStructSharp.dll
A parsed one-dimensional array of a fixed-width numeric primitive, stored as a T[].
It is the IList<T> of object the documented value table promises for
arrays - enumeration, indexing and passing it back to Serialize/Update all work - while
Span and ToArray() expose the values without boxing. Like a .NET array it is fixed
size: elements can be replaced through the indexer, never added or removed.
public sealed class PrimitiveArray<T> : IList<object?>, ICollection<object?>, IReadOnlyList<object?>, IReadOnlyCollection<object?>, IEnumerable<object?>, IList, ICollection, IEnumerable where T : unmanaged
Type Parameters
- Inheritance
-
PrimitiveArray<T>
- Implements
- Inherited Members
Constructors
PrimitiveArray(T[])
Wraps values without copying.
public PrimitiveArray(T[] values)
Parameters
valuesT[]The element storage; the array shares it.
Properties
Count
Gets the number of elements.
public int Count { get; }
Property Value
this[int]
Gets or replaces one element; the boxed element is a T, and a replacement is converted to T.
public object? this[int index] { get; set; }
Parameters
indexintThe zero-based element index.
Property Value
Memory
Gets the elements as typed read-only memory (no boxing).
public ReadOnlyMemory<T> Memory { get; }
Property Value
Span
Gets the elements as a typed read-only span (no boxing).
public ReadOnlySpan<T> Span { get; }
Property Value
- ReadOnlySpan<T>
Methods
Contains(object?)
Returns whether any element equals item.
public bool Contains(object? item)
Parameters
itemobjectThe value to find.
Returns
CopyTo(object?[], int)
Copies the boxed elements into array.
public void CopyTo(object?[] array, int arrayIndex)
Parameters
GetEnumerator()
Enumerates the elements as boxed values.
public IEnumerator<object?> GetEnumerator()
Returns
- IEnumerator<object>
An enumerator over the boxed elements.
IndexOf(object?)
Finds the first element equal to item.
public int IndexOf(object? item)
Parameters
itemobjectThe value to find; compared after conversion to
Twhen possible.
Returns
- int
The index, or -1.
ToArray()
Copies the elements into a new typed array.
public T[] ToArray()
Returns
- T[]
A fresh
T[] with the same values.
ToString()
Describes the array for debugging.
public override string ToString()
Returns
- string
The element type and count.