danmatrix / DanMatrix
Defined in: src/danMatrix.ts:22
DanMatrix is a class to handle two-dimension vectors, or matrices
T
is the type of element storable in the matrix
new DanMatrix<
T>(props?):DanMatrix<T>
Defined in: src/danMatrix.ts:36
The public constructor of DanMatrix
the optional input of type DanMatrixConstructorType
DanMatrix<T>
addColumn(
column):boolean
Defined in: src/danMatrix.ts:187
Add a column to the matrix
T[]
the column to be added
boolean
true if the new column was correctly added, otherwise it returns false
Error if a wrong input is passed
addRow(
row):boolean
Defined in: src/danMatrix.ts:170
Add a row to the matrix
T[]
the row to be added
boolean
true if the new row was correctly added, otherwise it returns false
Error if a wrong input is passed
clone():
DanMatrix<T>
Defined in: src/danMatrix.ts:73
Clone the current DanMatrix instance
DanMatrix<T>
a new DanMatrix instance equal to the current one
colsNum():
number
Defined in: src/danMatrix.ts:118
Get the number of columns of the matrix
number
the number of columns of the matrix
elementsNum():
number
Defined in: src/danMatrix.ts:129
Get the number of elements of the matrix
number
the number of elements of the matrix
get(
coord):T|undefined
Defined in: src/danMatrix.ts:138
Get the matrix value at (x, y)
the Coordinates instance (x,y) for rows and columns
T | undefined
the value at (x, y) or undefined if the coordinates are wrong
getAdjacentElements(
coord):DanMatrixElement<T>[] |undefined
Defined in: src/danMatrix.ts:236
Get all the adjacent elements given a specific coordinate
| top-left | top | top-right |
| left | element | right |
| bottom-left | bottom | bottom-right |
the coordinates of the element to get the adjacents from
DanMatrixElement<T>[] | undefined
the list of adjacent elements
getColumnAt(
columnIndex):T[] |undefined
Defined in: src/danMatrix.ts:380
Get matrix column at columnIndex
number
the column index
T[] | undefined
the requested column as array of values
Error if a wrong input is passed
getColumnsIterator():
DanMatrixColumnsIterator<T>
Defined in: src/danMatrix.ts:531
Get matrix columns iterator
the matrix columns iterator
getElementsIterator():
DanMatrixElementsIterator<T>
Defined in: src/danMatrix.ts:539
Get matrix elements iterator
the matrix elements iterator
getMatrixString(
fixedSpacing):string
Defined in: src/danMatrix.ts:83
Get a string representation of the current DanMatrix instance
number = 15
an optional numeric value for the cell spacing (default is 15)
string
a string representation of the current DanMatrix instance
getRowAt(
rowIndex):T[] |undefined
Defined in: src/danMatrix.ts:340
Get matrix row at rowIndex
number
the row index
T[] | undefined
the requested row as array of values
Error if a wrong input is passed
getRowsIterator():
DanMatrixRowsIterator<T>
Defined in: src/danMatrix.ts:523
Get matrix rows iterator
the matrix rows iterator
insertColumnAt(
columnIndex,column):boolean
Defined in: src/danMatrix.ts:401
Insert a column at the specific columnIndex index
number
the column index
T[]
the column to insert as an array of values
boolean
true if the new column was correctly inserted, otherwise it returns false
Error if a wrong input is passed
insertRowAt(
rowIndex,row):boolean
Defined in: src/danMatrix.ts:357
Insert a row at the specific rowIndex index
number
the row index
T[]
the row to insert as an array of values
boolean
true if the new row was correctly inserted, otherwise it returns false
Error if a wrong input is passed
lookForValue(
val):Coordinates[]
Defined in: src/danMatrix.ts:212
Look for a specific value inside the matrix
T
the value you're looking for
- an array of coordinates where the value was found
removeColumnAt(
columnIndex):boolean
Defined in: src/danMatrix.ts:454
Remove matrix column at index 'columnIndex'
number
the index of the column to be removed. If it's not an integer number or if it's less than zero, an exception "Error('Wrong input')" is thrown
boolean
true if the column removal was successful, otherwise it returns false
exception "Error('Wrong input')" when any parameter in input is wrong
removeRowAt(
rowIndex):boolean
Defined in: src/danMatrix.ts:436
Remove matrix row at index 'rowIndex'
number
the index of the row to be removed. If it's not an integer number or if it's less than zero, an exception "Error('Wrong input')" is thrown
boolean
true if the row removal was successful, otherwise it returns false
exception "Error('Wrong input')" when any parameter in input is wrong
replaceColumnAt(
columnIndex,column):boolean
Defined in: src/danMatrix.ts:503
Replace matrix column at index 'columnIndex'
number
the index of the column to be replaced. If it's not an integer number or if it's less than zero, an exception "Error('Wrong input')" is thrown
T[]
the array of values which must replace the existing column. If it's not an array or if the array is empty, an exception "Error('Wrong input')" is thrown
boolean
true if the column replacement was successful, otherwise it returns false
exception "Error('Wrong input')" when any parameter in input is wrong
replaceRowAt(
rowIndex,row):boolean
Defined in: src/danMatrix.ts:477
Replace matrix row at index 'rowIndex'
number
the index of the row to be replaced. If it's not an integer number or if it's less than zero, an exception "Error('Wrong input')" is thrown
T[]
the array of values which must replace the existing row. If it's not an array or if the array is empty, an exception "Error('Wrong input')" is thrown
boolean
true if the row replacement was successful, otherwise it returns false
exception "Error('Wrong input')" when any parameter in input is wrong
rowsNum():
number
Defined in: src/danMatrix.ts:110
Get the number of rows of the matrix
number
the number of rows of the matrix
set(
coord,val):T|undefined
Defined in: src/danMatrix.ts:151
Set a value at (x, y)
the Coordinates instance (x,y) for rows and columns
T
the value to set
T | undefined
the new value set at (x, y) or undefined if the coordinates are wrong
setupMatrix(
props?):void
Defined in: src/danMatrix.ts:46
The public method to setup the matrix
the optional input of type DanMatrixConstructorType
void
Error if a wrong input is passed