public final class TensorStreams
extends java.lang.Object
Entry<Position, T>
out of Tensors and collecting them back into
Tensors.Modifier and Type | Method and Description |
---|---|
static <T,CI,CO> java.util.function.Function<java.util.Map.Entry<Position,T>,java.util.Map.Entry<Position,T>> |
coordinatesOfType(java.lang.Class<CI> dimension,
java.util.function.Function<CI,CO> coordinateMapper) |
static <T> java.util.function.Function<java.util.Map.Entry<Position,T>,java.util.Map.Entry<Position,T>> |
positions(java.util.function.BiFunction<Position,T,Position> positionMapper) |
static <T> java.util.function.Function<java.util.Map.Entry<Position,T>,java.util.Map.Entry<Position,T>> |
positions(java.util.function.Function<Position,Position> positionMapper) |
static <S> java.util.stream.Stream<java.util.Map.Entry<Position,S>> |
tensorEntryStream(Tensor<S> tensor)
Return a stream of all entries of the tensor
|
static <V,T> TensorCollector<V,T> |
toTensor(java.util.function.Function<V,Position> positionMapper,
java.util.function.Function<V,T> valueMapper,
java.util.Set<java.lang.Class<?>> dimensions)
Build a collector to collect an arbitrary stream to a generic
Tensor<T> of the given dimensions. |
static <T> TensorCollector<java.util.Map.Entry<Position,T>,T> |
toTensor(java.util.Set<java.lang.Class<?>> dimensions)
Build a collector to collect a stream of
Entry<Position,T> to a generic Tensor<T> of the
dimensions defined in the set of classes. |
static <T,TB extends Tensorbacked<T>> |
toTensorbacked(java.lang.Class<TB> tensorBackedClass)
Build a collector to collect a stream of
Entry<Position,T> to a Tensorbacked<T> class. |
static <V,T,TB extends Tensorbacked<T>> |
toTensorbacked(java.lang.Class<TB> tensorBackedClass,
java.util.function.Function<V,Position> positionMapper,
java.util.function.Function<V,T> valueMapper)
Build a collector to collect an arbitrary stream to a Tensorbackedclass.
|
static <I,O> java.util.function.Function<java.util.Map.Entry<Position,I>,java.util.Map.Entry<Position,O>> |
values(java.util.function.BiFunction<Position,I,O> valueMapper) |
static <I,O> java.util.function.Function<java.util.Map.Entry<Position,I>,java.util.Map.Entry<Position,O>> |
values(java.util.function.Function<I,O> valueMapper) |
public static <S> java.util.stream.Stream<java.util.Map.Entry<Position,S>> tensorEntryStream(Tensor<S> tensor)
tensor
- public static <T> TensorCollector<java.util.Map.Entry<Position,T>,T> toTensor(java.util.Set<java.lang.Class<?>> dimensions)
Entry<Position,T>
to a generic Tensor<T>
of the
dimensions defined in the set of classes.dimensions
- the dimensions of the tensor to constructpublic static <V,T> TensorCollector<V,T> toTensor(java.util.function.Function<V,Position> positionMapper, java.util.function.Function<V,T> valueMapper, java.util.Set<java.lang.Class<?>> dimensions)
Tensor<T>
of the given dimensions.
Functions mapping the values to Position
and T must be provided.positionMapper
- function mapping stream values to PositionvalueMapper
- function mapping stream values to tensor valuesdimensions
- the dimensions of the tensor to constructpublic static <T,TB extends Tensorbacked<T>> TensorbackedCollector<java.util.Map.Entry<Position,T>,T,TB> toTensorbacked(java.lang.Class<TB> tensorBackedClass)
Entry<Position,T>
to a Tensorbacked<T>
class. The
Position
s in the stream must be consistent with the dimensions of the Tensorbacked.tensorBackedClass
- the tensorbacked to producepublic static <V,T,TB extends Tensorbacked<T>> TensorbackedCollector<V,T,TB> toTensorbacked(java.lang.Class<TB> tensorBackedClass, java.util.function.Function<V,Position> positionMapper, java.util.function.Function<V,T> valueMapper)
Position
and T must be provided. The Position
s generated must be consistent with the dimensions
of the Tensorbacked.tensorBackedClass
- the tensorbacked to producepositionMapper
- function mapping stream values to PositionvalueMapper
- function mapping stream values to tensor valuespublic static <T,CI,CO> java.util.function.Function<java.util.Map.Entry<Position,T>,java.util.Map.Entry<Position,T>> coordinatesOfType(java.lang.Class<CI> dimension, java.util.function.Function<CI,CO> coordinateMapper)
public static <T> java.util.function.Function<java.util.Map.Entry<Position,T>,java.util.Map.Entry<Position,T>> positions(java.util.function.Function<Position,Position> positionMapper)
public static <I,O> java.util.function.Function<java.util.Map.Entry<Position,I>,java.util.Map.Entry<Position,O>> values(java.util.function.Function<I,O> valueMapper)
public static <T> java.util.function.Function<java.util.Map.Entry<Position,T>,java.util.Map.Entry<Position,T>> positions(java.util.function.BiFunction<Position,T,Position> positionMapper)