Photon Fusion 2.0.3

Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
FixedArray< T > Class Template Reference

A fixed size array that can be used in structs. More...

Inherits IEnumerable< T >.

Classes

struct  Enumerator
 Enumerator for the FixedArray struct. More...
 

Public Member Functions

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 Public Member Functions

static unsafe FixedArray< T > Create< T > (ref T firstField, int length)
 Creates a FixedArray with a specified length. More...
 
static unsafe FixedArray< TAdapted > Create< TActual, TAdapted > (ref TActual firstField, int length)
 Creates a FixedArray with a specified length and adapts the type of the elements. More...
 
static unsafe FixedArray< T > CreateFromFieldSequence< T > (ref T firstField, ref T lastField)
 Creates a FixedArray from a sequence of fields. More...
 
static int IndexOf< T > (this FixedArray< T > array, T elem)
 Returns the index of the first occurrence of a value in the FixedArray. More...
 

Public Attributes

T * _array
 
int _length
 

Static Public Attributes

static StringBuilder _stringBuilderCached
 

Properties

int Length [get]
 The fixed size of the array. More...
 
ref T this[int index] [get]
 Indexer of array elements. More...
 

Detailed Description

A fixed size array that can be used in structs.

Helper methods for FixedArray.

Template Parameters
T
Type Constraints
T :unmanaged 

Constructor & Destructor Documentation

◆ FixedArray()

FixedArray ( T *  array,
int  length 
)

NetworkArray constructor.

Member Function Documentation

◆ Clear()

void 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
sourceThe source list from which to copy elements. Must not be null.
sourceOffsetThe zero-based index in the source list at which copying begins.
sourceCountThe number of elements to copy from the source list.
Exceptions
ArgumentNullExceptionThrown when the provided source list is null.
ArgumentExceptionThrown when the number of elements to copy is greater than the length of the FixedArray.
ArgumentOutOfRangeExceptionThrown 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
sourceThe source array from which to copy elements. Must not be null.
sourceOffsetThe zero-based index in the source array at which copying begins.
sourceCountThe number of elements to copy from the source array.
Exceptions
ArgumentNullExceptionThrown when the provided source array is null.
ArgumentExceptionThrown when the number of elements to copy is greater than the length of the FixedArray.
ArgumentOutOfRangeExceptionThrown 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
arrayThe array to copy values to. Must not be null.
throwIfOverflowIf 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
firstFieldReference to the first field in the array.
lengthThe length of the array.
Returns
A new FixedArray instance with the specified length.
Type Constraints
T :unmanaged 

◆ 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
firstFieldReference to the first field in the array.
lengthThe 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
firstFieldReference to the first field in the sequence.
lastFieldReference to the last field in the sequence.
Returns
A new FixedArray instance with the values from the sequence of fields.
Type Constraints
T :unmanaged 

◆ GetEnumerator()

Enumerator GetEnumerator ( )

Returns an enumerator that iterates through the FixedArray.

◆ IndexOf< T >()

static int IndexOf< T > ( this FixedArray< T >  array,
elem 
)
static

Returns the index of the first occurrence of a value in the FixedArray.

Parameters
arrayThe FixedArray to search.
elemThe value to locate in the FixedArray.
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()

T [] ToArray ( )

Allocates a new array and copies values from this array. For a non-alloc alternative use CopyTo(List<T>).

◆ ToListString()

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.

◆ ToString()

override string ToString ( )

Returns a string that represents the current object.

Property Documentation

◆ Length

int Length
get

The fixed size of the array.

◆ this[int index]

ref T this[int index]
get

Indexer of array elements.