Matrix (or, 2D Array) API

The Matrix data structure is essentially a 2-dimensional array.

.ds.matrix(data[, options]) or .ds.matrix(options)

A matrix can be initialized with the .ds.matrix() function of a JSAV instance. If the data argument is provided, it should be an array of arrays, all of the same length. If only options argument is provided, it needs to specify options rows and columns specifying the size of the matrix.

Matrix supports the common options and position options. Additional option that can be specified:

For example, this would create a 2x2 matrix: var m = jsav.ds.matrix([[0, 1], [2, 3]]). An empty 5x8 matrix using the matrix style could be created like this:

var m = jsav.ds.matrix({rows: 5, columns: 8, style: "matrix"});

.swap(row1, col1, row2, col2[, options])

Swaps two values of the matrix, namely (row1, col1) with (ro2, col2).

.layout([options])

Recalculates the layout for the data structure.

Array methods

Like for the array, there are similar functions in the matrix that take the row number as the first argument and the rest of the arguments similarly than the corresponding array function. These functions are highlight, unhighlight, isHighlight, css, value, addClass, hasClass, removeClass, and toggleClass. So, for example, whereas the array has function .addClass(col, className), the matrix has a function .addClass(row, col, className).