public interface TwoDimensionalReadAccess<T> extends MultiDimensionalReadAccess<T>
Modifier and Type | Interface and Description |
---|---|
static class |
TwoDimensionalReadAccess.Base<TT>
Base class implementing this interface which provides useful
default methods for
Object.toString() , Object.equals(Object) ,
and Object.hashCode() . |
Modifier and Type | Field and Description |
---|---|
static TwoDimensionalReadAccess<?> |
EMPTY
Empty acces, use
empty() instead. |
Modifier and Type | Method and Description |
---|---|
default TwoDimensionalReadAccess.Base<T> |
asBase()
View this class as if it has useful defaults for standard object methods.
|
static <E> TwoDimensionalReadAccess<E> |
empty()
Get an empty 2dimensional read access.
|
static <E> boolean |
equal(TwoDimensionalReadAccess<? extends E> access1,
TwoDimensionalReadAccess<? extends E> access2,
java.util.function.BiPredicate<E,E> equalityChecker)
Are two 2-dimensional accesses equal?
|
default T |
getElement(int... indexes)
Get the element located at the given indexes.
|
T |
getElementAt(int ix,
int iy)
Get the element at the given indexes.
|
default int |
getNumDimensions()
Get the number of dimensions used by this access,
|
default long |
getNumElements()
Get the combined number of elements in all dimensions.
|
default int |
getSize(int dim)
Get the size of the given dimension.
|
default int[] |
getSizes()
Get the sizes of the dimensions of this access.
|
static int |
hash(TwoDimensionalReadAccess<?> access)
Calculate a hashcode for a 2-dimensional read access..
|
static <E> TwoDimensionalReadAccess<E> |
singleton(E singleElement)
Get a 2dimensional read access for a single element.
|
int |
sizeX()
Get the number of elements in X direction.
|
int |
sizeY()
Get the number of elements in Y direction
|
default OneDimensionalReadAccess<T> |
subAtX(int ix)
Get a 1-dimensional view of the row at the given X index.
|
default OneDimensionalReadAccess<T> |
subAtY(int iy)
Get a 1-dimensional view of the column at the given X index.
|
static java.lang.String |
toString(TwoDimensionalReadAccess<?> access)
Create a string representation of an 2-dimensional read access.
|
default TwoDimensionalReadAccess<T> |
transposed()
Get a transposed view of this 2-dimensional read access.
|
default <TOUT> TwoDimensionalReadAccess<TOUT> |
view(java.util.function.Function<T,TOUT> conv)
Get a view of this two dimensional array with converted elements.
|
default void |
visitAll(Procedure1<? super T> visitor)
Visit all elements in this multi-dimensional array.
|
default void |
visitAll(Procedure2<? super T,int[]> visitor)
Visit all elements of this multi-dimensional array.
|
default java.lang.Iterable<OneDimensionalReadAccess<T>> |
xIterable()
Get an iterable which iterates over rows with constant X.
|
default java.util.Iterator<OneDimensionalReadAccess<T>> |
xIterator()
Get an iterator which iterates over rows with cnnstant X.
|
default java.lang.Iterable<OneDimensionalReadAccess<T>> |
yIterable()
Get an iterable which iterates over rows with constant Y.
|
default java.util.Iterator<OneDimensionalReadAccess<T>> |
yIterator()
Get an iterator which iterates over rows with cnnstant Y.
|
empty, linearized
static final TwoDimensionalReadAccess<?> EMPTY
empty()
instead.int sizeX()
int sizeY()
T getElementAt(int ix, int iy)
default T getElement(int... indexes)
MultiDimensionalReadAccess
getElement
in interface MultiDimensionalReadAccess<T>
indexes
- MultiDimensional.getNumDimensions()
indexes inside the bounds
defined by MultiDimensional.getSizes()
@NotNull default OneDimensionalReadAccess<T> subAtX(int ix)
ix
- X indexix
@NotNull default java.util.Iterator<OneDimensionalReadAccess<T>> xIterator()
@NotNull default java.lang.Iterable<OneDimensionalReadAccess<T>> xIterable()
@NotNull default java.util.Iterator<OneDimensionalReadAccess<T>> yIterator()
@NotNull default java.lang.Iterable<OneDimensionalReadAccess<T>> yIterable()
@NotNull default OneDimensionalReadAccess<T> subAtY(int iy)
iy
- Y indexiy
@NotNull default TwoDimensionalReadAccess<T> transposed()
default int getNumDimensions()
MultiDimensional
getNumDimensions
in interface MultiDimensional
default int getSize(int dim)
MultiDimensional
getSize
in interface MultiDimensional
dim
- dimension, greater than 0
and less than MultiDimensional.getNumDimensions()
@NotNull default int[] getSizes()
MultiDimensional
getSizes
in interface MultiDimensional
MultiDimensional.getNumDimensions()
default long getNumElements()
MultiDimensional
getNumElements
in interface MultiDimensional
@NotNull default <TOUT> TwoDimensionalReadAccess<TOUT> view(@NotNull java.util.function.Function<T,TOUT> conv)
TOUT
- element type provided by the viewconv
- element converterdefault void visitAll(@NotNull Procedure2<? super T,int[]> visitor)
MultiDimensionalReadAccess
visitAll
in interface MultiDimensionalReadAccess<T>
visitor
- visitor called with an array element and its multi-indexdefault void visitAll(@NotNull Procedure1<? super T> visitor)
MultiDimensionalReadAccess
visitAll
in interface MultiDimensionalReadAccess<T>
visitor
- element visitor called once with each element@NotNull default TwoDimensionalReadAccess.Base<T> asBase()
@NotNull static java.lang.String toString(@NotNull TwoDimensionalReadAccess<?> access)
access
- access to stringifystatic <E> boolean equal(@NotNull TwoDimensionalReadAccess<? extends E> access1, @NotNull TwoDimensionalReadAccess<? extends E> access2, @NotNull java.util.function.BiPredicate<E,E> equalityChecker)
E
- parameter type of equality checker, and super class of
both accesses element typeaccess1
- first accessaccess2
- second accessequalityChecker
- checker for equality of the elements of both objectstrue
if both accesses contain the same values in the same sequencefalse
if sizes or values differstatic int hash(@NotNull TwoDimensionalReadAccess<?> access)
access
- access for which the hash code is required@NotNull static <E> TwoDimensionalReadAccess<E> empty()
E
- element typeEMPTY
in a form the compiler accepts@NotNull static <E> TwoDimensionalReadAccess<E> singleton(E singleElement)
E
- element typesingleElement
- single element