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 ⇒
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. |
Horizontal size of the array
Kind: instance property of Table
Read only: true
Vertical size of the array.
Kind: instance property of Table
Read only: true
Table data organized by rows.
Kind: instance property of Table
Read only: true
Table data organized by columns.
Kind: instance property of Table
Read only: true
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. |
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. |
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. |
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. |
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. |
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. |
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. |
Returns a string representation of this table.
Kind: instance method of Table
Returns: string
- String representation of table.
Rotates table clockwise.
Kind: instance method of Table
Returns: Table.<T>
- New table.
Rotates table counterclockwise.
Kind: instance method of Table
Returns: Table.<T>
- New table.
Flips table horizontally.
Kind: instance method of Table
Returns: Table.<T>
- New table.
Flips table vertically.
Kind: instance method of Table
Returns: Table.<T>
- New table.
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. |
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. |
Kind: inner typedef of Table
Returns: T
- Value for given coordinates.
Param | Type | Description |
---|---|---|
x | number |
X coordinate. |
y | number |
Y coordinate. |
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. |
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. |
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. |