E
- type of this abstract 1D matrixabstract class AbstractMatrix1D<E> extends Object implements Matrix1D<E>
Modifier and Type | Field and Description |
---|---|
protected boolean |
isView
True if this instance is a view.
|
protected long |
size
Size.
|
protected long |
stride
Number of indices between any two elements.
|
protected long |
zero
Index of the first element.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractMatrix1D()
Protected no-arg constructor, to support serialization.
|
protected |
AbstractMatrix1D(long size)
Create a new abstract 1D matrix with the specified size.
|
protected |
AbstractMatrix1D(long size,
long zero,
long stride,
boolean isView)
Create a new abstract 1D matrix with the specified parameters.
|
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 1D matrix and aggregate
the result.
|
E |
aggregate(Matrix1D<? extends E> other,
BinaryFunction<E,E,E> aggr,
BinaryFunction<E,E,E> function)
Apply a function to each value in this 1D matrix and the specified
matrix and aggregate the result.
|
Matrix1D<E> |
assign(E e)
Assign all values in this 1D matrix to
e (optional operation). |
Matrix1D<E> |
assign(Matrix1D<? extends E> other)
Assign all values in this 1D matrix to the values in the
specified matrix (optional operation).
|
Matrix1D<E> |
assign(Matrix1D<? extends E> other,
BinaryFunction<E,E,E> function)
Assign the result of the specified function of a value from
this 1D matrix and the specified matrix to each value in this
1D matrix (optional operation).
|
Matrix1D<E> |
assign(UnaryFunction<E,E> function)
Assign the result of the specified function to each value
in this 1D matrix (optional operation).
|
long |
cardinality()
Return the cardinality of this 1D matrix, the number
of non-null values.
|
void |
clear()
Clear all the values in this 1D matrix (optional operation).
|
void |
forEach(BinaryPredicate<Long,? super E> predicate,
BinaryProcedure<Long,? super E> procedure)
Apply the specified procedures to each index and value in this
1D matrix accepted by the specified predicate.
|
void |
forEach(BinaryProcedure<Long,? super E> procedure)
Apply the specified procedures to each index and value in this
1D matrix.
|
void |
forEach(UnaryPredicate<? super E> predicate,
UnaryProcedure<? super E> procedure)
Apply the specified procedure to each value in this 1D matrix
accepted by the specified predicate.
|
void |
forEach(UnaryProcedure<? super E> procedure)
Apply the specified procedure to each value in this 1D matrix.
|
void |
forEachNonNull(UnaryProcedure<? super E> procedure)
Apply the specified procedure to each non-null value in this 1D matrix.
|
E |
get(long index)
Return the value at the specified index.
|
boolean |
isEmpty()
Return true if the cardinality of this 1D matrix is zero.
|
protected boolean |
isView()
Return true if this instance is a view.
|
Iterator<E> |
iterator()
Return an iterator over the values in this 1D matrix, including
null s. |
void |
set(long index,
E e)
Set the value at the specified index to
e (optional operation). |
void |
setQuick(long index,
E e)
Set the value at the specified index to
e without
checking bounds (optional operation). |
long |
size()
Return the size of this 1D matrix.
|
protected long |
stride()
Return the number of indices between any two elements.
|
String |
toString() |
protected AbstractMatrix1D<E> |
vFlip()
Self-modifying version of
viewFlip() . |
protected AbstractMatrix1D<E> |
view()
Create a new view.
|
Matrix1D<E> |
viewFlip()
Return a new 1D matrix flip view.
|
Matrix1D<E> |
viewPart(long index,
long width)
Return a new 1D matrix sub-range view that contains only those values
from index
index to index + width - 1 . |
Matrix1D<E> |
viewSelection(BitMatrix1D mask)
Return a new 1D matrix selection view that contains only those values
at the indices present in the specified bit mask.
|
Matrix1D<E> |
viewSelection(long[] indices)
Return a new 1D matrix selection view that contains only those values
at the specified indices.
|
Matrix1D<E> |
viewSelection(UnaryPredicate<E> predicate)
Return a new 1D matrix selection view that contains only those values
selected by the specified predicate.
|
Matrix1D<E> |
viewStrides(long stride)
Return a new 1D matrix stride view which is a sub matrix
consisting of every i-th value in this matrix.
|
protected AbstractMatrix1D<E> |
vPart(long index,
long width)
Self-modifying version of
viewPart(long, long) . |
protected AbstractMatrix1D<E> |
vStrides(long stride)
Self-modifying version of
viewStrides(long) . |
protected long |
zero()
Return the index of the first element.
|
protected long size
protected long zero
protected long stride
protected boolean isView
protected AbstractMatrix1D()
protected AbstractMatrix1D(long size)
size
- size, must be >= 0
IllegalArgumentException
- if size
is negativeprotected AbstractMatrix1D(long size, long zero, long stride, boolean isView)
size
- size, must be >= 0
zero
- index of the first elementstride
- number of indices between any two elementsisView
- true if this instance is a viewpublic long size()
public long cardinality()
cardinality
in interface Matrix1D<E>
public boolean isEmpty()
public void clear()
public Iterator<E> iterator()
null
s.public E get(long index)
public void set(long index, E e)
e
(optional operation).public void setQuick(long index, E e)
e
without
checking bounds (optional operation).public Matrix1D<E> assign(E e)
e
(optional operation).public Matrix1D<E> assign(UnaryFunction<E,E> function)
public Matrix1D<E> assign(Matrix1D<? extends E> other)
public Matrix1D<E> assign(Matrix1D<? extends E> other, BinaryFunction<E,E,E> function)
public E aggregate(BinaryFunction<E,E,E> aggr, UnaryFunction<E,E> function)
public E aggregate(Matrix1D<? extends E> other, BinaryFunction<E,E,E> aggr, BinaryFunction<E,E,E> function)
protected AbstractMatrix1D<E> view()
protected AbstractMatrix1D<E> vFlip()
viewFlip()
.this
public Matrix1D<E> viewFlip()
0
is now index size() - 1
, ..., what used to
be index size() - 1
is now index 0
. The
view is backed by this matrix, so changes made to the returned view
are reflected in this matrix, and vice-versa.protected AbstractMatrix1D<E> vPart(long index, long width)
viewPart(long, long)
.index
- indexwidth
- widththis
public Matrix1D<E> viewPart(long index, long width)
index
to index + width - 1
.
The view is backed by this matrix, so changes made to the returned
view are reflected in this matrix, and vice-versa.public Matrix1D<E> viewSelection(long[] indices)
viewSelection
in interface Matrix1D<E>
indices
- indicespublic Matrix1D<E> viewSelection(UnaryPredicate<E> predicate)
viewSelection
in interface Matrix1D<E>
predicate
- predicate, must not be nullpublic Matrix1D<E> viewSelection(BitMatrix1D mask)
viewSelection
in interface Matrix1D<E>
mask
- 1D bit mask, must not be nullprotected AbstractMatrix1D<E> vStrides(long stride)
viewStrides(long)
.stride
- stridethis
public Matrix1D<E> viewStrides(long stride)
viewStrides
in interface Matrix1D<E>
stride
- stride, must be > 0
public void forEach(UnaryProcedure<? super E> procedure)
For example:
Matrix1D<String> m; m.forEach(new UnaryProcedure<String>() { public void run(final String value) { System.out.println(value); } });
public void forEach(UnaryPredicate<? super E> predicate, UnaryProcedure<? super E> procedure)
For example:
Matrix1D<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); } });
public void forEachNonNull(UnaryProcedure<? super E> procedure)
For example:
Matrix1D<String> m; m.forEachNonNull(new UnaryProcedure<String>() { public void run(final String value) { System.out.println(value); } });
forEachNonNull
in interface Matrix1D<E>
procedure
- procedure, must not be nullpublic void forEach(BinaryProcedure<Long,? super E> procedure)
For example:
Matrix1D<String> m; m.forEach(new BinaryProcedure<Long, String>() { public void run(final Long index, final String value) { System.out.print("m[" + index + "]=" + value); } });
public void forEach(BinaryPredicate<Long,? super E> predicate, BinaryProcedure<Long,? super E> procedure)
For example:
Matrix1D<String> m; m.forEach(new BinaryPredicate<Long, String>() { public boolean test(final Long index, final String value) { return (value != null); } }, new BinaryProcedure<Long, String>() { public void run(final Long index, final String value) { System.out.print("m[" + index + "]=" + value); } });
protected long zero()
protected long stride()
protected boolean isView()
Copyright (c) 2004-2013 held jointly by the individual authors. Licensed under the GNU Lesser General Public License (LGPL).