X - the type of the vector elementspublic class Vector<X>
extends java.lang.Object
For specific instantiations of this class for group and ring elements,
see GroupElementVector and RingElementVector.
| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<? extends X> |
values |
| Modifier | Constructor and Description |
|---|---|
|
Vector(java.util.List<? extends X> values) |
protected |
Vector(java.util.List<? extends X> values,
boolean isSafe)
Construct a new
Vector using the given values which are assumed to be safe
(promised to not be changed from the outside). |
|
Vector(Vector<? extends X> values) |
|
Vector(X... values) |
protected |
Vector(X[] values,
boolean isSafe)
Construct a new
Vector using the given values which are assumed to be safe
(promised to not be changed from the outside). |
| Modifier and Type | Method and Description |
|---|---|
Vector<X> |
append(X valueToAppend) |
Vector<X> |
concatenate(Vector<? extends X> secondPart) |
boolean |
equals(java.lang.Object o) |
void |
forEach(java.util.function.BiConsumer<java.lang.Integer,X> consumer) |
void |
forEach(java.util.function.Consumer<X> consumer) |
protected static <Z,V extends Vector<Z>> |
fromStreamPlain(java.util.stream.Stream<? extends Z> stream,
java.util.function.Function<java.util.List<Z>,V> vectorInstantiator) |
static <Z> Vector<Z> |
fromStreamPlain(java.util.stream.Stream<Z> stream) |
static <Y> Vector<Y> |
generatePlain(java.util.function.Function<java.lang.Integer,? extends Y> generator,
int n)
Generates a new
Vector<Y> of length n by applying the generator function to each
index. |
static <Y,V extends Vector<Y>> |
generatePlain(java.util.function.Function<java.lang.Integer,? extends Y> generator,
int n,
java.util.function.Function<java.util.List<Y>,V> vectorInstantiator)
Generates a new
Vector V<Y> of length n by applying the generator function
to each index. |
static <Y> Vector<Y> |
generatePlain(java.util.function.Supplier<? extends Y> generator,
int n)
Generates a new
Vector<Y> of length n using the generator supplier. |
static <Y,V extends Vector<Y>> |
generatePlain(java.util.function.Supplier<? extends Y> generator,
int n,
java.util.function.Function<java.util.List<Y>,V> vectorInstantiator)
Generates a new
Vector V<Y> of length n using the generator supplier. |
X |
get(int index) |
int |
hashCode() |
static <Y> Vector<Y> |
iterate(Y initialValue,
java.util.function.Function<Y,Y> nextValue,
int n)
Constructs a new
Vector<Y> with n elements by applying the nextValue function
n times, storing each result in the resulting vector. |
protected static <Y,V extends Vector<Y>> |
iterate(Y initialValue,
java.util.function.Function<Y,Y> nextValue,
int n,
java.util.function.Function<java.util.List<Y>,V> vectorInstantiator)
Constructs a new
Vector V<Y> with n elements by applying the nextValue function
n times, storing each result in the resulting vector. |
int |
length() |
<Y> Vector<Y> |
map(java.util.function.BiFunction<java.lang.Integer,X,Y> map) |
<Y,V extends Vector<Y>> |
map(java.util.function.BiFunction<java.lang.Integer,X,Y> map,
java.util.function.Function<java.util.List<Y>,? extends V> vectorInstantiator) |
<Y> Vector<Y> |
map(java.util.function.Function<X,Y> map) |
<Y,V extends Vector<Y>> |
map(java.util.function.Function<X,Y> map,
java.util.function.Function<java.util.List<Y>,? extends V> vectorInstantiator) |
static GroupElementVector |
of(GroupElement... vals)
Construct a new
GroupElementVector made up of the given group elements. |
static RingElementVector |
of(RingElement... vals)
Construct a new
RingElementVector made up of the given group elements. |
static <Y> Vector<Y> |
of(Y... vals)
Construct a new
Vector made up of the given values. |
Vector<X> |
pad(X valueToPadWith,
int desiredLength) |
Vector<X> |
prepend(X valueToPrepend) |
X |
reduce(java.util.function.BinaryOperator<X> combiner) |
X |
reduce(java.util.function.BinaryOperator<X> combiner,
X neutralElement) |
Vector<X> |
replace(int index,
X substitute) |
java.util.stream.Stream<? extends X> |
stream() |
java.util.List<X> |
toList() |
java.lang.String |
toString() |
Vector<X> |
truncate(int newLength) |
<Y,Z> Vector<Z> |
zip(Vector<Y> other,
java.util.function.BiFunction<X,Y,Z> combiner) |
protected <Y,Z,V extends Vector<Z>> |
zip(Vector<Y> other,
java.util.function.BiFunction<X,Y,Z> combiner,
java.util.function.Function<java.util.List<Z>,V> vectorInstantiator) |
<Y,Z> Z |
zipReduce(Vector<Y> other,
java.util.function.BiFunction<X,Y,Z> zipMap,
java.util.function.BinaryOperator<Z> combiner)
Equivalent to zip(other, zipMap).reduce(combiner, neutralElement)
|
<Y,Z> Z |
zipReduce(Vector<Y> other,
java.util.function.BiFunction<X,Y,Z> zipMap,
java.util.function.BinaryOperator<Z> combiner,
Z neutralElement)
Equivalent to zip(other, zipMap).reduce(combiner, neutralElement)
|
protected java.util.List<? extends X> values
public Vector(X... values)
public Vector(java.util.List<? extends X> values)
protected Vector(X[] values, boolean isSafe)
Vector using the given values which are assumed to be safe
(promised to not be changed from the outside).values - the values to construct the new Vector fromisSafe - whether the given value array is "safe" in the sense that it is promised to not be changed
from the outside afterwardsprotected Vector(java.util.List<? extends X> values, boolean isSafe)
Vector using the given values which are assumed to be safe
(promised to not be changed from the outside).values - the values to construct the new Vector fromisSafe - whether the given value array is "safe" in the sense that it is promised to not be changed
from the outside afterwardspublic static <Y> Vector<Y> of(Y... vals)
Vector made up of the given values.Y - the type of the elementsvals - the values to use for constructing the new VectorVector filled with the given elementspublic static GroupElementVector of(GroupElement... vals)
GroupElementVector made up of the given group elements.vals - the values to use for constructing the new GroupElementVectorGroupElementVector filled with the given elementspublic static RingElementVector of(RingElement... vals)
RingElementVector made up of the given group elements.vals - the values to use for constructing the new RingElementVectorRingElementVector filled with the given elementspublic static <Y> Vector<Y> iterate(Y initialValue, java.util.function.Function<Y,Y> nextValue, int n)
Vector<Y> with n elements by applying the nextValue function
n times, storing each result in the resulting vector.Y - the type of the vector valuesinitialValue - the first value of the resulting vector and the basis for the successive valuesnextValue - the function producing values for the resulting vectorn - the length of the resulting vectorn produced by iterative application of the nextValue functioniterate(Object, Function, int, Function)protected static <Y,V extends Vector<Y>> V iterate(Y initialValue, java.util.function.Function<Y,Y> nextValue, int n, java.util.function.Function<java.util.List<Y>,V> vectorInstantiator)
Vector V<Y> with n elements by applying the nextValue function
n times, storing each result in the resulting vector.Y - the type of the vector valuesV - the type of the vector itselfinitialValue - the first value of the resulting vector and the basis for the successive valuesnextValue - the function producing values for the resulting vectorn - the length of the resulting vectorvectorInstantiator - the function that instantiates the vector given a list of valuesn produced by iterative application of the nextValue functionpublic static <Y> Vector<Y> generatePlain(java.util.function.Function<java.lang.Integer,? extends Y> generator, int n)
Vector<Y> of length n by applying the generator function to each
index.Y - the type of the vector elementsgenerator - the function that creates the vector elementsn - the desired number of elementsVector<Y> of length npublic static <Y> Vector<Y> generatePlain(java.util.function.Supplier<? extends Y> generator, int n)
Vector<Y> of length n using the generator supplier.Y - the type of the vector elementsgenerator - the function that creates the vector elementsn - the desired number of elementsVector<Y> of length npublic static <Y,V extends Vector<Y>> V generatePlain(java.util.function.Function<java.lang.Integer,? extends Y> generator, int n, java.util.function.Function<java.util.List<Y>,V> vectorInstantiator)
Vector V<Y> of length n by applying the generator function
to each index.Y - the type of the vector elementsV - the type of vectorgenerator - the function that creates the vector elementsn - the desired number of elementsvectorInstantiator - the function that instantiates the vector given a list of valuesVector<Y> of length npublic static <Y,V extends Vector<Y>> V generatePlain(java.util.function.Supplier<? extends Y> generator, int n, java.util.function.Function<java.util.List<Y>,V> vectorInstantiator)
Vector V<Y> of length n using the generator supplier.Y - the type of the vector elementsV - the type of vectorgenerator - the function that creates the vector elementsn - the desired number of elementsvectorInstantiator - the function that instantiates the vector given a list of valuesVector<Y> of length nprotected static <Z,V extends Vector<Z>> V fromStreamPlain(java.util.stream.Stream<? extends Z> stream, java.util.function.Function<java.util.List<Z>,V> vectorInstantiator)
public static <Z> Vector<Z> fromStreamPlain(java.util.stream.Stream<Z> stream)
protected <Y,Z,V extends Vector<Z>> V zip(Vector<Y> other, java.util.function.BiFunction<X,Y,Z> combiner, java.util.function.Function<java.util.List<Z>,V> vectorInstantiator)
public <Y,V extends Vector<Y>> V map(java.util.function.Function<X,Y> map, java.util.function.Function<java.util.List<Y>,? extends V> vectorInstantiator)
public <Y,V extends Vector<Y>> V map(java.util.function.BiFunction<java.lang.Integer,X,Y> map, java.util.function.Function<java.util.List<Y>,? extends V> vectorInstantiator)
public void forEach(java.util.function.Consumer<X> consumer)
public void forEach(java.util.function.BiConsumer<java.lang.Integer,X> consumer)
public <Y,Z> Z zipReduce(Vector<Y> other, java.util.function.BiFunction<X,Y,Z> zipMap, java.util.function.BinaryOperator<Z> combiner, Z neutralElement)
public <Y,Z> Z zipReduce(Vector<Y> other, java.util.function.BiFunction<X,Y,Z> zipMap, java.util.function.BinaryOperator<Z> combiner)
public java.util.List<X> toList()
public java.util.stream.Stream<? extends X> stream()
public int length()
public X get(int index)
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object