Hatch Game Engine Documentation v1.4.0
The documentation for the Hatch Game Engine
Loading...
Searching...
No Matches
Array Class Reference

Array manipulation. More...

Public Member Functions

value Create (integer size, value initialValue)
 Creates an array.
integer Length (array array)
 Gets the length of an array.
void Push (array array, value value)
 Adds a value to the end of an array.
value Pop (array array)
 Gets the value at the end of an array, and removes it.
void Insert (array array, integer index, value value)
 Inserts a value at an index of an array.
void Erase (array array, integer index)
 Erases a value at an index of an array.
void Clear (array array)
 Clears an array.
void Shift (array array, boolean toRight)
 Rotates the array in the desired direction.
void SetAll (array array, integer startIndex, integer endIndex, value value)
 Sets values in the array from startIndex to endIndex (includes the value at endIndex.).
void Reverse (array array, integer startIndex=0, integer endIndex)
 Reverses the elements of an array through the specified range, exclusive. The array is reversed from startIndex to, but not including, endIndex.
void Sort (array array, function compFunction)
 Sorts the entries of the given array.

Detailed Description

Array manipulation.

Member Function Documentation

◆ Clear()

void Array.Clear ( array array)

Clears an array.

Parameters
arrayArray to clear.

◆ Create()

value Array.Create ( integer size,
value initialValue )

Creates an array.

Parameters
sizeSize of the array.
initialValueInitial value to set the array elements to.
Returns
A reference value to the array.

◆ Erase()

void Array.Erase ( array array,
integer index )

Erases a value at an index of an array.

Parameters
arrayArray to erase value.
indexIndex to erase value.

◆ Insert()

void Array.Insert ( array array,
integer index,
value value )

Inserts a value at an index of an array.

Parameters
arrayArray to insert value.
indexIndex to insert value.
valueValue to insert.

◆ Length()

integer Array.Length ( array array)

Gets the length of an array.

Parameters
arrayArray to get the length of.
Returns
Length of the array.

◆ Pop()

value Array.Pop ( array array)

Gets the value at the end of an array, and removes it.

Parameters
arrayArray to get the length of.
Returns
The value from the end of the array.

◆ Push()

void Array.Push ( array array,
value value )

Adds a value to the end of an array.

Parameters
arrayArray to get the length of.
valueValue to add to the array.

◆ Reverse()

void Array.Reverse ( array array,
integer startIndex = 0,
integer endIndex )

Reverses the elements of an array through the specified range, exclusive. The array is reversed from startIndex to, but not including, endIndex.

Parameters
arrayArray to reverse.
startIndexStart range.
endIndexEnd range. (default: size of array)

◆ SetAll()

void Array.SetAll ( array array,
integer startIndex,
integer endIndex,
value value )

Sets values in the array from startIndex to endIndex (includes the value at endIndex.).

Parameters
arrayArray to set values to.
startIndexIndex of value to start setting. (-1 for first index)
endIndexIndex of value to end setting. (-1 for last index)
valueValue to set to.

◆ Shift()

void Array.Shift ( array array,
boolean toRight )

Rotates the array in the desired direction.

Parameters
arrayArray to shift.
toRightWhether to rotate the array to the right or not.

◆ Sort()

void Array.Sort ( array array,
function compFunction )

Sorts the entries of the given array.

Parameters
arrayArray to sort.
compFunctionComparison function. If not given, a default comparison function is used; the entries of the array are sorted in ascending order, and non-numeric values do not participate in the comparison.