E
- type of this sparse 2D matrixpublic class SparseMatrix2D<E> extends AbstractMatrix2D<E> implements Serializable
Long
s.
The cardinality of this sparse object matrix is limited
by the HashMap
underlying this implementation
to something less than Integer.MAX_VALUE
. The
addressable size, on the other hand, is limited to
(rows * columns) < Long.MAX_VALUE
.
columns, columnStride, columnZero, isView, rows, rowStride, rowZero
Modifier | Constructor and Description |
---|---|
|
SparseMatrix2D(long rows,
long columns)
Create a new sparse 2D matrix with the specified number
of rows and columns.
|
|
SparseMatrix2D(long rows,
long columns,
int initialCapacity,
float loadFactor)
Create a new sparse 2D matrix with the specified number
of rows and columns, initial capacity, and load factor.
|
protected |
SparseMatrix2D(long rows,
long columns,
long rowZero,
long columnZero,
long rowStride,
long columnStride,
boolean isView,
Map<Long,E> elements)
Create a new instance of SparseMatrix2D with the specified
parameters and map of elements.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear all the values in this 2D matrix (optional operation).
|
Object |
clone() |
protected Map<Long,E> |
elements()
Return a reference to the map backing this sparse 2D matrix.
|
void |
forEachNonNull(UnaryProcedure<? super E> procedure)
Apply the specified procedure to each non-null value in this 2D matrix.
|
E |
getQuick(long row,
long column)
Return the value at the specified row and column without
checking bounds.
|
void |
setQuick(long row,
long column,
E e)
Set the value at the specified row and column to
e without checking bounds (optional operation). |
String |
toString() |
Matrix1D<E> |
viewColumn(long column)
Return a new 1D matrix slice view of the specified column.
|
Matrix1D<E> |
viewRow(long row)
Return a new 1D matrix slice view of the specified row.
|
aggregate, aggregate, assign, assign, assign, assign, cardinality, columns, columnStride, columnZero, forEach, forEach, forEach, forEach, get, isEmpty, isView, iterator, rows, rowStride, rowZero, set, size, vColumnFlip, vDice, view, viewColumnFlip, viewDice, viewPart, viewRowFlip, viewSelection, viewSelection, viewSelection, viewStrides, vPart, vRowFlip, vStrides
public SparseMatrix2D(long rows, long columns)
rows
- rows, must be >= 0
columns
- columns, must be >= 0
IllegalArgumentException
- if either rows
or columns
is negativepublic SparseMatrix2D(long rows, long columns, int initialCapacity, float loadFactor)
rows
- rows, must be >= 0
columns
- columns, must be >= 0
initialCapacity
- initial capacity, must be >= 0
loadFactor
- load factor, must be > 0
protected SparseMatrix2D(long rows, long columns, long rowZero, long columnZero, long rowStride, long columnStride, boolean isView, Map<Long,E> elements)
clone()
method.rows
- rows, must be >= 0
columns
- columns, must be >= 0
rowZero
- row of the first elementcolumnZero
- column of the first elementrowStride
- number of rows between two elementscolumnStride
- number of columns between two elementsisView
- true if this instance is a viewelements
- map of elementspublic E getQuick(long row, long column)
public void setQuick(long row, long column, E e)
e
without checking bounds (optional operation).public void clear()
public void forEachNonNull(UnaryProcedure<? super E> procedure)
For example:
Matrix2D<String> m; m.forEachNonNull(new UnaryProcedure<String>() { public void run(final String value) { System.out.println(value); } });Overridden for performance.
forEachNonNull
in interface Matrix2D<E>
forEachNonNull
in class AbstractMatrix2D<E>
procedure
- procedure, must not be nullpublic Matrix1D<E> viewRow(long row)
public Matrix1D<E> viewColumn(long column)
viewColumn
in interface Matrix2D<E>
column
- column index, must be >= 0
and < columns()
protected Map<Long,E> elements()
public String toString()
toString
in class AbstractMatrix2D<E>
Copyright (c) 2004-2013 held jointly by the individual authors. Licensed under the GNU Lesser General Public License (LGPL).