public class TwoDimensionalArray<T> extends TwoDimensionalReadAccess.Base<T> implements TwoDimensionalAccess<T>
TwoDimensionalReadAccess.Base<TT>
EMPTY
Constructor and Description |
---|
TwoDimensionalArray(int sy,
java.util.Collection<T> elements)
Constructor.
|
TwoDimensionalArray(int sy,
Indexable<T> elements)
Constructor.
|
TwoDimensionalArray(int sx,
int sy)
Constructor.
|
TwoDimensionalArray(int sx,
int sy,
IntFunction2<? extends T> filler)
Initializing constructor.
|
TwoDimensionalArray(int sx,
int sy,
java.lang.Iterable<T> elements)
Constructor.
|
TwoDimensionalArray(int sy,
T... elements)
Constructor.
|
TwoDimensionalArray(java.util.function.Supplier<? extends T> supplier,
int sx,
int sy)
Constructor.
|
TwoDimensionalArray(TwoDimensionalReadAccess<T> source)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
<R> TwoDimensionalArray<R> |
getCopy(java.util.function.Function<? super T,? extends R> copier)
Get an independent copy with a possibly different element type.
|
T |
getElementAt(int ix,
int iy)
Get the element at the given indexes.
|
TwoDimensionalArray<T> |
resized(int sx,
int sy)
Get a resized copy of this array which contains the same elements for equal indexes.
|
<R> TwoDimensionalArray<R> |
resized(int sx,
int sy,
java.util.function.Function<? super T,? extends R> copier,
IntFunction2<? extends R> filler)
Get a resized copy of this array.
|
TwoDimensionalArray<T> |
resized(int sx,
int sy,
IntFunction2<? extends T> filler)
Get a resized copy of this array.
|
void |
setElementAt(T element,
int ix,
int iy)
Set the element at the given indexes.
|
int |
sizeX()
Get the number of elements in X direction.
|
int |
sizeY()
Get the number of elements in Y direction
|
asBase, equals, hashCode, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
changeAll, changeAll, createConstant, createIndexed, createNulled, createSupplied, empty, fillByIndex, setElement, subAtX, subAtY, transposed, zeroX, zeroY
asBase, equal, getElement, getNumDimensions, getNumElements, getSize, getSizes, hash, singleton, toString, view, visitAll, visitAll, xIterable, xIterator, yIterable, yIterator
change, setAll, setFrom, setFrom, setFrom
empty, linearized
public TwoDimensionalArray(int sx, int sy)
null
.sx
- size in X direction (at least 1
)sy
- size in Y direction (at least 1
)TwoDimensionalArray(int, int, IntFunction2)
public TwoDimensionalArray(int sx, int sy, @NotNull IntFunction2<? extends T> filler)
sx
- size in X direction (at least 1
)sy
- size in Y direction (at least 1
)filler
- function called with all index combinations (x,y)public TwoDimensionalArray(@NotNull java.util.function.Supplier<? extends T> supplier, int sx, int sy)
supplier
for each cell and fill it with the result.sx
- size in X direction (at least 1
)sy
- size in Y direction (at least 1
)supplier
- supplier for cell content@SafeVarargs public TwoDimensionalArray(int sy, T... elements)
sy
- size in Y direction (at least 1
)elements
- sx * sy
elementspublic TwoDimensionalArray(int sy, @NotNull java.util.Collection<T> elements)
sy
- size in Y direction (at least 1
)elements
- sx * sy
elementspublic TwoDimensionalArray(int sy, @NotNull Indexable<T> elements)
sy
- size in Y direction (at least 1
)elements
- sx * sy
elementspublic TwoDimensionalArray(int sx, int sy, @NotNull java.lang.Iterable<T> elements)
sx
- size in X direction (at least 1
)sy
- size in Y direction (at least 1
)elements
- at least sx * sy
elementspublic TwoDimensionalArray(@NotNull TwoDimensionalReadAccess<T> source)
source
- source accesspublic void setElementAt(T element, int ix, int iy)
TwoDimensionalAccess
setElementAt
in interface TwoDimensionalAccess<T>
element
- element to setix
- index in X direction from 0
(included) to TwoDimensionalReadAccess.sizeX()
(excluded)iy
- index in Y direction from 0
(included) to TwoDimensionalReadAccess.sizeY()
(excluded)public int sizeX()
TwoDimensionalReadAccess
sizeX
in interface TwoDimensionalReadAccess<T>
public int sizeY()
TwoDimensionalReadAccess
sizeY
in interface TwoDimensionalReadAccess<T>
public T getElementAt(int ix, int iy)
TwoDimensionalReadAccess
getElementAt
in interface TwoDimensionalReadAccess<T>
ix
- index in X direction from 0
(included) to TwoDimensionalReadAccess.sizeX()
(excluded)iy
- index in Y direction from 0
(included) to TwoDimensionalReadAccess.sizeY()
(excluded)@NotNull public <R> TwoDimensionalArray<R> getCopy(@NotNull java.util.function.Function<? super T,? extends R> copier)
R
- target element typecopier
- copier which copies elements from this 2dimensional array to the result array.@NotNull public TwoDimensionalArray<T> resized(int sx, int sy)
sx
- new size in X directionsy
- new size in Y directionnull
@NotNull public TwoDimensionalArray<T> resized(int sx, int sy, @Nullable IntFunction2<? extends T> filler)
sx
- new size in X directionsy
- new size in Y directionfiller
- filler for newly created cells, use null
to leave them empty@NotNull public <R> TwoDimensionalArray<R> resized(int sx, int sy, @NotNull java.util.function.Function<? super T,? extends R> copier, @Nullable IntFunction2<? extends R> filler)
R
- possibly different type of resulting arraysx
- new size in X directionsy
- new size in Y directioncopier
- function which copies elementsfiller
- filler for newly created cells, use null
to leave them empty