Photon Quantum 3.0.0

Static Public Member Functions | List of all members
Quantum.ArrayUtils Class Reference

A collection of utility methods for working with arrays. More...

Static Public Member Functions

static void Add< T > (ref T[] array, T item)
 Add one item to the array and resize it accordingly. More...
 
static T[] AddAtStart< T > (T[] array, T item)
 Copy an array and add an array element to the start of the array. More...
 
static T[] Clone< T > (this T[] array)
 Clone an array. More...
 
static T[][] CreateGrid< T > (int rows, int cols)
 Create and initialize a 2-dimensional array. Instantiates rows number of arrays, each with cols number of elements. More...
 
static B[] Map< A, B > (this A[] array, Func< A, B > map)
 Create a new array and map each element of the input array to a new value. More...
 
static B[] Map< A, B > (this List< A > array, Func< A, B > map)
 Create a new array and map each element of the input list to a new value. More...
 
static B[] MapRef< A, B > (this A[] array, Func< A, B > map)
 Create a new array an map each element of the input list to a new value. Different to Map<A, B>(A[], Func<A, B>) null values are preserved. More...
 
static T[] RemoveAtStart< T > (T[] array)
 Copy an array and remove an element from the start of the array. More...
 
static T[] Slice< T > (this T[] array, int slice)
 Copy the array but only the first slice elements. More...
 

Detailed Description

A collection of utility methods for working with arrays.

Member Function Documentation

◆ CreateGrid< T >()

static T [][] Quantum.ArrayUtils.CreateGrid< T > ( int  rows,
int  cols 
)
inlinestatic

Create and initialize a 2-dimensional array. Instantiates rows number of arrays, each with cols number of elements.

Template Parameters
TThe array type
Parameters
rowsNumber of rows
colsNumber of columns
Returns
An array of array object

◆ Add< T >()

static void Quantum.ArrayUtils.Add< T > ( ref T[]  array,
item 
)
inlinestatic

Add one item to the array and resize it accordingly.

Template Parameters
TArray type
Parameters
arrayArray to add to
itemItem to add to the array

◆ Clone< T >()

static T [] Quantum.ArrayUtils.Clone< T > ( this T[]  array)
inlinestatic

Clone an array.

Template Parameters
TArray type
Parameters
arrayArray to clone
Returns
A new array which is a clone of the input array

◆ AddAtStart< T >()

static T [] Quantum.ArrayUtils.AddAtStart< T > ( T[]  array,
item 
)
inlinestatic

Copy an array and add an array element to the start of the array.

Template Parameters
TArray type
Parameters
arrayArray to add to
itemItem to add in from of the array
Returns
A new array with the element added in front.

◆ RemoveAtStart< T >()

static T [] Quantum.ArrayUtils.RemoveAtStart< T > ( T[]  array)
inlinestatic

Copy an array and remove an element from the start of the array.

Template Parameters
TArray type
Parameters
arrayArray to remove from
Returns
A new array with the element removed in the front.

◆ Map< A, B >() [1/2]

static B [] Quantum.ArrayUtils.Map< A, B > ( this A[]  array,
Func< A, B >  map 
)
inlinestatic

Create a new array and map each element of the input array to a new value.

Template Parameters
AInput array type
BOutput array type
Parameters
arrayArray to map
mapThe mapping method
Returns
A new array with the same length as the input array and with mapped items

◆ Map< A, B >() [2/2]

static B [] Quantum.ArrayUtils.Map< A, B > ( this List< A >  array,
Func< A, B >  map 
)
inlinestatic

Create a new array and map each element of the input list to a new value.

Template Parameters
AInput list type
BOutput array type
Parameters
arrayList to map
mapThe mapping method
Returns
A new array with the same length as the input list and with mapped items

◆ Slice< T >()

static T [] Quantum.ArrayUtils.Slice< T > ( this T[]  array,
int  slice 
)
inlinestatic

Copy the array but only the first slice elements.

Template Parameters
TArray type
Parameters
arrayArray to copy
sliceThe number of elements to copy
Returns
A new array with a given number of first elements

◆ MapRef< A, B >()

static B [] Quantum.ArrayUtils.MapRef< A, B > ( this A[]  array,
Func< A, B >  map 
)
inlinestatic

Create a new array an map each element of the input list to a new value. Different to Map<A, B>(A[], Func<A, B>) null values are preserved.

Template Parameters
AInput list type
BOutput array type
Parameters
arrayList to map
mapThe mapping method
Returns
A new array with the same length as the input list and with mapped items
Type Constraints
A :class 
B :class