Index

Immutable index. Warning: the input array is NOT cloned, modifying it will modify the index values.

Constructor

new Index(values)

Parameters:
NameTypeDescription
valuesArray.<number>

The index values.

Classes

Index

Methods

add(rhs) → {Index}

Add another index to this one.

Parameters:
NameTypeDescription
rhsIndex

The index to add.

Returns:

The index representing the sum of both indices.

Type: 
Index

canCompare(rhs) → {boolean}

Check if the input index can be compared to this one.

Parameters:
NameTypeDescription
rhsIndex

The index to compare to.

Returns:

True if both indices are comparable.

Type: 
boolean

compare(rhs) → {Array.<number>}

Compare indices and return different dimensions.

Parameters:
NameTypeDescription
rhsIndex

The index to compare to.

Returns:

The list of different dimensions.

Type: 
Array.<number>

equals(rhs) → {boolean}

Check for Index equality.

Parameters:
NameTypeDescription
rhsIndex

The index to compare to.

Returns:

True if both indices are equal.

Type: 
boolean

get(i) → {number|undefined}

Get the index value at the given array index.

Parameters:
NameTypeDescription
inumber

The index to get.

Returns:

The value or undefined if not in range.

Type: 
number | undefined

getValues() → {Array.<number>}

Get the values of this index.

Returns:

The array of values.

Type: 
Array.<number>

getWithNew2D(i, j) → {Index}

Get the current index with a new 2D base.

Parameters:
NameTypeDescription
inumber

The new 0 index.

jnumber

The new 1 index.

Returns:

The new index.

Type: 
Index

length() → {number}

Get the length of the index.

Returns:

The length.

Type: 
number

toString() → {string}

Get a string representation of the Index.

Returns:

The Index as a string.

Type: 
string