Class: Matrix

Matrix

Very simple object-backed bi-dimensional Matrix implementation.

new Matrix(inputMatrix)

Creates a Matrix instance; if specified the matrix is initialized with the given object.
Parameters:
Name Type Description
inputMatrix Object the matrix to initialize this object with.

Method Summary

del
Removes the element at the specified position in the matrix.
delRow
Removes the row at the specified position in the matrix.
get
Gets the element at the specified position in the matrix.
getEntireMatrix
Gets a full matrix.
getRow
Gets a full row from the matrix.
insert
Inserts an element in the matrix.
insertRow
Inserts a full row in the matrix.

Method Detail

del(row, column)

Removes the element at the specified position in the matrix.
Parameters:
Name Type Description
row String | Number the row in the matrix where the element is located.
column String | Number the column in the row where the element is located.

delRow(row)

Removes the row at the specified position in the matrix.
Parameters:
Name Type Description
row String | Number the row position.

get(row, column) → {Object}

Gets the element at the specified position in the matrix. If the position is empty null is returned.
Parameters:
Name Type Description
row String | Number the row in the matrix where the element is located.
column String | Number the column in the row where the element is located.
Returns:
the element at the specified location or null.
Type
Object

getEntireMatrix()

Gets a full matrix. Note that the actual internal matrix is returned so that any change performed on it will reflect on the Matrix itself
Returns:
the full internal matrix.

getRow(row)

Gets a full row from the matrix. Note that the actual row object is returned so that any change performed on it will reflect on the Matrix itself
Parameters:
Name Type Description
row String | Number the row position.
Returns:
the full row or null.

insert(insObject, row, column)

Inserts an element in the matrix. If another element is already present in the specified position it is overwritten.
Parameters:
Name Type Description
insObject Object the element to be added.
row String | Number the row in the matrix where the element is placed.
column String | Number the column in the row where the element is placed.

insertRow(insRow, row)

Inserts a full row in the matrix. If another row is already present in the specified position it is overwritten.
Parameters:
Name Type Description
insRow Object the row to be added.
row String | Number the row position.