E
- type of this 2D matrixpublic interface Matrix2D<E> extends Iterable<E>
long
s.Modifier and Type | Method and Description |
---|---|
E |
aggregate(BinaryFunction<E,E,E> aggr,
UnaryFunction<E,E> function)
Apply a function to each value in this 2D matrix and aggregate
the result.
|
E |
aggregate(Matrix2D<? extends E> other,
BinaryFunction<E,E,E> aggr,
BinaryFunction<E,E,E> function)
Apply a function to each value in this 2D matrix and the specified
matrix and aggregate the result.
|
Matrix2D<E> |
assign(E e)
Assign all values in this 2D matrix to
e (optional operation). |
Matrix2D<E> |
assign(Matrix2D<? extends E> other)
Assign all values in this 2D matrix to the values in the
specified matrix (optional operation).
|
Matrix2D<E> |
assign(Matrix2D<? extends E> other,
BinaryFunction<E,E,E> function)
Assign the result of the specified function of a value from
this 2D matrix and the specified matrix to each value in this
2D matrix (optional operation).
|
Matrix2D<E> |
assign(UnaryFunction<E,E> function)
Assign the result of the specified function to each value
in this 2D matrix (optional operation).
|
long |
cardinality()
Return the cardinality of this 2D matrix, the number
of non-null values.
|
void |
clear()
Clear all the values in this 2D matrix (optional operation).
|
long |
columns()
Return the number of columns in this 2D matrix.
|
void |
forEach(TernaryPredicate<Long,Long,? super E> predicate,
TernaryProcedure<Long,Long,? super E> procedure)
Apply the specified procedures to each row and column
and to each value in this 2D matrix accepted by the specified predicate.
|
void |
forEach(TernaryProcedure<Long,Long,? super E> procedure)
Apply the specified procedures to each row and column and
to each value in this 2D matrix.
|
void |
forEach(UnaryPredicate<? super E> predicate,
UnaryProcedure<? super E> procedure)
Apply the specified procedure to each value in this 2D matrix
accepted by the specified predicate.
|
void |
forEach(UnaryProcedure<? super E> procedure)
Apply the specified procedure to each value in this 2D matrix.
|
void |
forEachNonNull(UnaryProcedure<? super E> procedure)
Apply the specified procedure to each non-null value in this 2D matrix.
|
E |
get(long row,
long column)
Return the value at the specified row and column.
|
E |
getQuick(long row,
long column)
Return the value at the specified row and column without
checking bounds.
|
boolean |
isEmpty()
Return true if the cardinality of this 2D matrix is zero.
|
Iterator<E> |
iterator()
Return an iterator over the values in this 2D matrix, including
null s. |
long |
rows()
Return the number of rows in this 2D matrix.
|
void |
set(long row,
long column,
E e)
Set the value at the specified row and column to
e (optional
operation). |
void |
setQuick(long row,
long column,
E e)
Set the value at the specified row and column to
e without checking bounds (optional operation). |
long |
size()
Return the size of this 2D matrix.
|
Matrix1D<E> |
viewColumn(long column)
Return a new 1D matrix slice view of the specified column.
|
Matrix2D<E> |
viewColumnFlip()
Return a new 2D matrix flip view along the column axis.
|
Matrix2D<E> |
viewDice()
Return a new 2D matrix dice (transposition) view.
|
Matrix2D<E> |
viewPart(long row,
long column,
long height,
long width)
Return a new 2D matrix sub-range view that contains only those values
from
(row, column) to
(row + height - 1, column + width - 1) . |
Matrix1D<E> |
viewRow(long row)
Return a new 1D matrix slice view of the specified row.
|
Matrix2D<E> |
viewRowFlip()
Return a new 2D matrix flip view along the row axis.
|
Matrix2D<E> |
viewSelection(BitMatrix2D mask)
Return a new 2D matrix selection view that contains only those values
at the indices present in the specified bit mask.
|
Matrix2D<E> |
viewSelection(long[] rowIndices,
long[] columnIndices)
Return a new 2D matrix selection view that contains only those values at the
specified indices.
|
Matrix2D<E> |
viewSelection(UnaryPredicate<Matrix1D<E>> predicate)
Return a new 2D matrix selection view that contains only those rows
selected by the specified predicate.
|
Matrix2D<E> |
viewStrides(long rowStride,
long columnStride)
Return a new 2D matrix stride view which is a sub matrix consisting
of every
rowStride -th row and every columnStride -th
column. |
long size()
long rows()
long columns()
long cardinality()
boolean isEmpty()
void clear()
UnsupportedOperationException
- if the clear
operation
is not supported by this 2D matrixE get(long row, long column)
row
- row index, must be >= 0
and < rows()
column
- column index, must be >= 0
and < columns()
IndexOutOfBoundsException
- if row
or column
is negative or if row
or column
is greater than
or equal to rows()
or columns()
, respectivelyE getQuick(long row, long column)
row
- row index, should be >= 0
and < rows()
(unchecked)column
- column index, should be >= 0
and < columns()
(unchecked)void set(long row, long column, E e)
e
(optional
operation).row
- row index, must be >= 0
and < rows()
column
- column index, must be >= 0
and < columns()
e
- valueIndexOutOfBoundsException
- if row
or column
is negative or if row
or column
is greater than
or equal to rows()
or columns()
, respectivelyUnsupportedOperationException
- if the set
operation
is not supported by this 2D matrixvoid setQuick(long row, long column, E e)
e
without checking bounds (optional operation).row
- row index, should be >= 0
and < rows()
(unchecked)column
- column index, should be >= 0
and < columns()
(unchecked)e
- valueUnsupportedOperationException
- if the setQuick
operation
is not supported by this 2D matrixIterator<E> iterator()
null
s.Matrix2D<E> assign(E e)
e
(optional operation).e
- valueUnsupportedOperationException
- if this assign
operation
is not supported by this 2D matrixMatrix2D<E> assign(UnaryFunction<E,E> function)
function
- function, must not be nullUnsupportedOperationException
- if this assign
operation
is not supported by this 2D matrixMatrix2D<E> assign(Matrix2D<? extends E> other)
other
- other 2D matrix, must not be null and must
have the same dimensions as this 2D matrixUnsupportedOperationException
- if this assign
operation
is not supported by this 2D matrixMatrix2D<E> assign(Matrix2D<? extends E> other, BinaryFunction<E,E,E> function)
other
- other 2D matrix, must not be null and must
have the same dimensions as this 2D matrixfunction
- function, must not be nullUnsupportedOperationException
- if this assign
operation
is not supported by this 2D matrixE aggregate(BinaryFunction<E,E,E> aggr, UnaryFunction<E,E> function)
aggr
- aggregate function, must not be nullfunction
- function, must not be nullE aggregate(Matrix2D<? extends E> other, BinaryFunction<E,E,E> aggr, BinaryFunction<E,E,E> function)
other
- other 2D matrix, must not be null and must
have the same dimensions as this 2D matrixaggr
- aggregate function, must not be nullfunction
- function, must not be nullMatrix1D<E> viewRow(long row)
row
- row index, must be >= 0
and < rows()
IndexOutOfBoundsException
- if row
is negative or if
row
is greater than or equal to rows()
Matrix1D<E> viewColumn(long column)
column
- column index, must be >= 0
and < columns()
IndexOutOfBoundsException
- if column
is negative or if
column
is greater than or equal to columns()
Matrix2D<E> viewDice()
view.get(row, column) == this.get(column, row)
.
The view is backed by this matrix, so changes made to the returned
view are reflected in this matrix, and vice-versa.Matrix2D<E> viewRowFlip()
0
is now row rows() - 1
,
..., what used to be row rows() - 1
is now row 0
.
The view is backed by this matrix, so changes made to the returned
view are reflected in this matrix, and vice-versa.Matrix2D<E> viewColumnFlip()
0
is now column columns() - 1
,
..., what used to be column columns() - 1
is now column
0
. The view is backed by this matrix, so changes made to the
returned view are reflected in this matrix, and vice-versa.Matrix2D<E> viewPart(long row, long column, long height, long width)
(row, column)
to
(row + height - 1, column + width - 1)
.
The view is backed by this matrix, so changes made to the returned
view are reflected in this matrix, and vice-versa.row
- row index, must be >= 0
and < rows()
column
- column index, must be >= 0
and < columns()
height
- heightwidth
- width(row, column)
to
(row + height - 1, column + width - 1)
.Matrix2D<E> viewSelection(long[] rowIndices, long[] columnIndices)
rowIndices
- row indicescolumnIndices
- column indicesMatrix2D<E> viewSelection(UnaryPredicate<Matrix1D<E>> predicate)
predicate
- predicate, must not be nullMatrix2D<E> viewSelection(BitMatrix2D mask)
mask
- 2D bit mask, must not be nullMatrix2D<E> viewStrides(long rowStride, long columnStride)
rowStride
-th row and every columnStride
-th
column. The view is backed by this matrix, so changes made to the returned view
are reflected in this matrix, and vice-versa.rowStride
- row stride, must be > 0
columnStride
- column stride, must be > 0
rowStride
-th row and every columnStride
-th
columnIndexOutOfBoundsException
- if either rowStride
or columnStride
are negative or zerovoid forEach(UnaryProcedure<? super E> procedure)
For example:
Matrix2D<String> m; m.forEach(new UnaryProcedure<String>() { public void run(final String value) { System.out.println(value); } });
procedure
- procedure, must not be nullvoid forEach(UnaryPredicate<? super E> predicate, UnaryProcedure<? super E> procedure)
For example:
Matrix2D<String> m; m.forEach(new UnaryPredicate<String>() { public boolean test(final String value) { return (value != null); } }, new UnaryProcedure<String>() { public void run(final String value) { System.out.println(value); } });
predicate
- predicate, must not be nullprocedure
- procedure, must not be nullvoid 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); } });
procedure
- procedure, must not be nullvoid forEach(TernaryProcedure<Long,Long,? super E> procedure)
For example:
Matrix2D<String> m; m.forEach(new TernaryProcedure<Long, Long, String>() { public void run(final Long row, final Long column, final String value) { System.out.print("m[" + row + ", " + column + "]=" + value); } });
procedure
- procedure, must not be nullvoid forEach(TernaryPredicate<Long,Long,? super E> predicate, TernaryProcedure<Long,Long,? super E> procedure)
For example:
Matrix2D<String> m; m.forEach(new TernaryPredicate<Long, Long, String>() { public boolean test(final Long row, final Long column, final String value) { return (value != null); } }, new TernaryProcedure<Long, Long, String>() { public void run(final Long row, final Long column, final String value) { System.out.print("m[" + row + ", " + column + "]=" + value); } });
predicate
- predicate, must not be nullprocedure
- procedure, must not be nullCopyright (c) 2004-2013 held jointly by the individual authors. Licensed under the GNU Lesser General Public License (LGPL).