A fixed size array that can be used in structs.
More...
Inherits IEnumerable< T >.
|
void | Clear () |
| Sets all elements in the array to their default value. More...
|
|
void | CopyFrom (List< T > source, int sourceOffset, int sourceCount) |
| Copies a range of elements from a source list into the FixedArray. More...
|
|
void | CopyFrom (T[] source, int sourceOffset, int sourceCount) |
| Copies a range of elements from a source array into the FixedArray. More...
|
|
void | CopyTo (List< T > list) |
| Adds each value to the supplied List. This does not clear the list, so values will be appended to the existing list. More...
|
|
void | CopyTo (T[] array, bool throwIfOverflow=true) |
| Copies values to the supplied array. More...
|
|
| FixedArray (T *array, int length) |
| NetworkArray constructor. More...
|
|
Enumerator | GetEnumerator () |
| Returns an enumerator that iterates through the FixedArray. More...
|
|
IEnumerator< T > IEnumerable< T >. | GetEnumerator () |
|
IEnumerator IEnumerable. | GetEnumerator () |
|
T[] | ToArray () |
| Allocates a new array and copies values from this array. For a non-alloc alternative use CopyTo(List<T>). More...
|
|
string | ToListString () |
| Returns the elements of this array as a string, with value separated by
characters. Specifically for use in the Unity inspector. This is private and only is found by NetworkBehaviourEditor using reflection, so do not rename this method. More...
|
|
override string | ToString () |
| Returns a string that represents the current object. More...
|
|
|
static StringBuilder | _stringBuilderCached |
|
A fixed size array that can be used in structs.
Helper methods for FixedArray.
- Template Parameters
-
◆ FixedArray()
◆ Clear()
Sets all elements in the array to their default value.
◆ CopyFrom() [1/2]
void CopyFrom |
( |
List< T > |
source, |
|
|
int |
sourceOffset, |
|
|
int |
sourceCount |
|
) |
| |
Copies a range of elements from a source list into the FixedArray.
- Parameters
-
source | The source list from which to copy elements. Must not be null. |
sourceOffset | The zero-based index in the source list at which copying begins. |
sourceCount | The number of elements to copy from the source list. |
- Exceptions
-
ArgumentNullException | Thrown when the provided source list is null. |
ArgumentException | Thrown when the number of elements to copy is greater than the length of the FixedArray. |
ArgumentOutOfRangeException | Thrown when the sum of sourceOffset and sourceCount is greater than the length of the source list. |
◆ CopyFrom() [2/2]
void CopyFrom |
( |
T[] |
source, |
|
|
int |
sourceOffset, |
|
|
int |
sourceCount |
|
) |
| |
Copies a range of elements from a source array into the FixedArray.
- Parameters
-
source | The source array from which to copy elements. Must not be null. |
sourceOffset | The zero-based index in the source array at which copying begins. |
sourceCount | The number of elements to copy from the source array. |
- Exceptions
-
ArgumentNullException | Thrown when the provided source array is null. |
ArgumentException | Thrown when the number of elements to copy is greater than the length of the FixedArray. |
ArgumentOutOfRangeException | Thrown when the sum of sourceOffset and sourceCount is greater than the length of the source array. |
◆ CopyTo() [1/2]
void CopyTo |
( |
List< T > |
list | ) |
|
Adds each value to the supplied List. This does not clear the list, so values will be appended to the existing list.
◆ CopyTo() [2/2]
void CopyTo |
( |
T[] |
array, |
|
|
bool |
throwIfOverflow = true |
|
) |
| |
Copies values to the supplied array.
- Parameters
-
array | The array to copy values to. Must not be null. |
throwIfOverflow | If true, this method will throw an error if the supplied array is smaller than this NetworkArray<T>. If false, will only copy as many elements as the target array can hold. |
◆ Create< T >()
static unsafe FixedArray<T> Create< T > |
( |
ref T |
firstField, |
|
|
int |
length |
|
) |
| |
|
static |
Creates a FixedArray with a specified length.
- Parameters
-
firstField | Reference to the first field in the array. |
length | The length of the array. |
- Returns
- A new FixedArray instance with the specified length.
◆ Create< TActual, TAdapted >()
static unsafe FixedArray<TAdapted> Create< TActual, TAdapted > |
( |
ref TActual |
firstField, |
|
|
int |
length |
|
) |
| |
|
static |
Creates a FixedArray with a specified length and adapts the type of the elements.
- Parameters
-
firstField | Reference to the first field in the array. |
length | The length of the array. |
- Returns
- A new FixedArray instance with the specified length and adapted type of elements.
- Type Constraints
-
TActual | : | unmanaged | |
TAdapted | : | unmanaged | |
◆ CreateFromFieldSequence< T >()
static unsafe FixedArray<T> CreateFromFieldSequence< T > |
( |
ref T |
firstField, |
|
|
ref T |
lastField |
|
) |
| |
|
static |
Creates a FixedArray from a sequence of fields.
- Parameters
-
firstField | Reference to the first field in the sequence. |
lastField | Reference to the last field in the sequence. |
- Returns
- A new FixedArray instance with the values from the sequence of fields.
◆ GetEnumerator()
Returns an enumerator that iterates through the FixedArray.
◆ IndexOf< T >()
static int IndexOf< T > |
( |
this FixedArray< T > |
array, |
|
|
T |
elem |
|
) |
| |
|
static |
Returns the index of the first occurrence of a value in the FixedArray.
- Parameters
-
- Returns
- The zero-based index of the first occurrence of elem within the entire FixedArray, if found; otherwise, -1.
- Type Constraints
-
T | : | unmanaged | |
T | : | IEquatable<T> | |
◆ ToArray()
Allocates a new array and copies values from this array. For a non-alloc alternative use CopyTo(List<T>).
◆ ToListString()
Returns the elements of this array as a string, with value separated by
characters. Specifically for use in the Unity inspector. This is private and only is found by NetworkBehaviourEditor using reflection, so do not rename this method.
◆ ToString()
override string ToString |
( |
| ) |
|
Returns a string that represents the current object.
◆ Length
The fixed size of the array.
◆ this[int index]
Indexer of array elements.