Table
Represents a two-dimensional array of data.
Kind: global class
Template: T Type of data that will be stored by this table.
- Table
- new Table(width, height, [callbackfn])
- instance
- .width :
number
- .height :
number
- .rows :
Array.<Array.<?T>>
- .cols :
Array.<Array.<?T>>
- .set(x, y, value) ⇒
Table.<T>
- .get(x, y) ⇒
T
- .row(y) ⇒
Array.<?T>
- .col(x) ⇒
Array.<?T>
- .map(callbackfn) ⇒
Table.<U>
- .reduce(callbackfn, initialValue) ⇒
U
- .forEach(callbackfn, [thisArg])
- .toString() ⇒
string
- .cw() ⇒
Table.<T>
- .ccw() ⇒
Table.<T>
- .flipX() ⇒
Table.<T>
- .flipY() ⇒
Table.<T>
- .width :
- static
- .fromRows(rows) ⇒
Table.<U>
- .fromCols(cols) ⇒
Table.<U>
- .fromRows(rows) ⇒
- inner
- ~constructorCallback ⇒
T
- ~mapCallback ⇒
U
- ~reduceCallback ⇒
U
- ~forEachCallback :
function
- ~constructorCallback ⇒
new Table(width, height, [callbackfn])
Creates an instance of Table.
Param | Type | Description |
---|---|---|
width | number |
Horizontal size of the array. |
height | number |
Vertical size of the array. |
[callbackfn] | constructorCallback |
This function is used to populate table during initialization. |
number
table.width : Horizontal size of the array
Kind: instance property of Table
Read only: true
number
table.height : Vertical size of the array.
Kind: instance property of Table
Read only: true
Array.<Array.<?T>>
table.rows : Table data organized by rows.
Kind: instance property of Table
Read only: true
Array.<Array.<?T>>
table.cols : Table data organized by columns.
Kind: instance property of Table
Read only: true
Table.<T>
table.set(x, y, value) ⇒ Sets a value at given coordinates.
If one of the coordinates equals null, value will be set for the whole row/column.
Kind: instance method of Table
Returns: Table.<T>
- This table.
Param | Type | Description |
---|---|---|
x | number |
X index. |
y | number |
Y index. |
value | T |
Value to be set. |
T
table.get(x, y) ⇒ Returns value at given coordinates.
Kind: instance method of Table
Returns: T
- Value at given coordinates.
Param | Type | Description |
---|---|---|
x | number |
X index. |
y | number |
Y index. |
Array.<?T>
table.row(y) ⇒ Returns a specific row.
Kind: instance method of Table
Returns: Array.<?T>
- Row of data.
Param | Type | Description |
---|---|---|
y | number |
Index of a row to be returned. |
Array.<?T>
table.col(x) ⇒ Returns a specific column.
Kind: instance method of Table
Returns: Array.<?T>
- Column of data.
Param | Type | Description |
---|---|---|
x | number |
Index of a column to be returned. |
Table.<U>
table.map(callbackfn) ⇒ Creates new table using this table values.
Kind: instance method of Table
Returns: Table.<U>
- New table.
Template: U Type of data that will be stored by new table.
Param | Type | Description |
---|---|---|
callbackfn | mapCallback |
This function is used to populate new table using current table values. |
U
table.reduce(callbackfn, initialValue) ⇒ Calls the specified callback function for all table values and returns accumulation result.
Kind: instance method of Table
Returns: U
- Accumulation result.
Template: U Type of accumulation result.
Param | Type | Description |
---|---|---|
callbackfn | reduceCallback |
The reduce method calls this function one time for each value of the table. |
initialValue | U |
If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of a table value. |
table.forEach(callbackfn, [thisArg])
Performs the specified action for each element in a table.
Kind: instance method of Table
Param | Type | Description |
---|---|---|
callbackfn | forEachCallback |
Function called one time for each element in the table. |
[thisArg] | * |
An object to which the this keyword can refer in the callbackfn function. |
string
table.toString() ⇒ Returns a string representation of this table.
Kind: instance method of Table
Returns: string
- String representation of table.
Table.<T>
table.cw() ⇒ Rotates table clockwise.
Kind: instance method of Table
Returns: Table.<T>
- New table.
Table.<T>
table.ccw() ⇒ Rotates table counterclockwise.
Kind: instance method of Table
Returns: Table.<T>
- New table.
Table.<T>
table.flipX() ⇒ Flips table horizontally.
Kind: instance method of Table
Returns: Table.<T>
- New table.
Table.<T>
table.flipY() ⇒ Flips table vertically.
Kind: instance method of Table
Returns: Table.<T>
- New table.
Table.<U>
Table.fromRows(rows) ⇒ Returns a new table populated with values from given array.
It handles variable rows length by setting null for missing values.
Kind: static method of Table
Returns: Table.<U>
- New table with given values.
Template: U Type of data that will be stored by new table.
Param | Type | Description |
---|---|---|
rows | Array.<Array.<?U>> |
Table data organized by rows. |
Table.<U>
Table.fromCols(cols) ⇒ Returns a new table populated with values from given array.
It handles variable columns length by setting null for missing values.
Kind: static method of Table
Returns: Table.<U>
- New table with given values.
Template: U Type of data that will be stored by new table.
Param | Type | Description |
---|---|---|
cols | Array.<Array.<?U>> |
Table data organized by columns. |
T
Table~constructorCallback ⇒ Kind: inner typedef of Table
Returns: T
- Value for given coordinates.
Param | Type | Description |
---|---|---|
x | number |
X coordinate. |
y | number |
Y coordinate. |
U
Table~mapCallback ⇒ Kind: inner typedef of Table
Returns: U
- New value for given coordinates.
Param | Type | Description |
---|---|---|
value | T |
Current value at given coordinates. |
x | number |
X coordinate. |
y | number |
Y coordinate. |
table | Table.<T> |
Current table. |
U
Table~reduceCallback ⇒ Kind: inner typedef of Table
Returns: U
- Accumulation result.
Param | Type | Description |
---|---|---|
previousValue | U |
Previous accumulation result. |
currentValue | T |
Value at given coordinates. |
currentX | number |
X coordinate. |
currentY | number |
Y coordinate. |
table | Table.<T> |
Current table. |
function
Table~forEachCallback : Kind: inner typedef of Table
Param | Type | Description |
---|---|---|
value | T |
Value at given coordinates. |
x | number |
X coordinate. |
y | number |
Y coordinate. |
table | Table.<T> |
Current table. |