public class Vector<T> extends java.lang.Object implements ImmutableList<T>, java.io.Serializable, Higher<DataWitness.vector,T>
ImmutableList.None<T>, ImmutableList.Some<T>
Constructor and Description |
---|
Vector(BAMT.NestedArray<T> root,
BAMT.ActiveTail<T> tail,
int size) |
Modifier and Type | Method and Description |
---|---|
Vector<T> |
append(T value) |
Vector<T> |
appendAll(java.lang.Iterable<? extends T> value) |
Vector<T> |
appendAll(T... values) |
Vector<ReactiveSeq<T>> |
combinations() |
Vector<ReactiveSeq<T>> |
combinations(int size) |
Vector<T> |
combine(java.util.function.BiPredicate<? super T,? super T> predicate,
java.util.function.BinaryOperator<T> op)
Combine two adjacent elements in a traversable using the supplied BinaryOperator
This is a stateful grouping and reduction operation.
|
Vector<T> |
combine(Monoid<T> op,
java.util.function.BiPredicate<? super T,? super T> predicate)
Combine two adjacent elements in a traversable using the supplied BinaryOperator
This is a stateful grouping and reduction operation.
|
<R> Vector<R> |
concatMap(java.util.function.Function<? super T,? extends java.lang.Iterable<? extends R>> fn)
Perform a flatMap operation on this IterableX.
|
boolean |
containsValue(T value) |
Vector<T> |
cycle(long times) |
Vector<T> |
cycle(Monoid<T> m,
long times) |
Vector<T> |
cycleUntil(java.util.function.Predicate<? super T> predicate) |
Vector<T> |
cycleWhile(java.util.function.Predicate<? super T> predicate) |
Either<java.lang.Integer,Vector<T>> |
delete(int pos) |
Vector<T> |
deleteBetween(int start,
int end)
Delete elements between given indexes
|
Vector<T> |
distinct() |
Vector<T> |
drop(long num)
assertThat(ReactiveSeq.of(4,3,6,7).drop(2).toList(),equalTo(Arrays.asList(6,7))); |
Vector<T> |
dropRight(int num)
Generate a new Traversable that drops the specified number elements from the take of this Traversable
|
Vector<T> |
dropUntil(java.util.function.Predicate<? super T> p)
Generate a new Traversable that drops elements from this Traversable until the predicate holds
|
Vector<T> |
dropWhile(java.util.function.Predicate<? super T> p)
Generate a new Traversable that drops elements from this Traversable as long as the predicate holds
|
static <T> Vector<T> |
empty() |
Vector<T> |
emptyUnit() |
boolean |
equals(java.lang.Object o) |
static <T> Vector<T> |
fill(T t,
int max) |
Vector<T> |
filter(java.util.function.Predicate<? super T> pred)
Keep only elements for which the supplied predicates hold
e.g.
|
Vector<T> |
filterNot(java.util.function.Predicate<? super T> predicate)
Remove any elements for which the predicate holds (inverse operation to filter)
e.g.
|
<R> Vector<R> |
flatMap(java.util.function.Function<? super T,? extends ImmutableList<? extends R>> fn) |
<R> R |
fold(java.util.function.Function<? super ImmutableList.Some<T>,? extends R> fn1,
java.util.function.Function<? super ImmutableList.None<T>,? extends R> fn2) |
<R1,R> Vector<R> |
forEach2(java.util.function.Function<? super T,? extends java.lang.Iterable<R1>> iterable1,
java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction) |
<R1,R> Vector<R> |
forEach2(java.util.function.Function<? super T,? extends java.lang.Iterable<R1>> iterable1,
java.util.function.BiFunction<? super T,? super R1,java.lang.Boolean> filterFunction,
java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction) |
<R1,R2,R> Vector<R> |
forEach3(java.util.function.Function<? super T,? extends java.lang.Iterable<R1>> iterable1,
java.util.function.BiFunction<? super T,? super R1,? extends java.lang.Iterable<R2>> iterable2,
Function3<? super T,? super R1,? super R2,? extends R> yieldingFunction) |
<R1,R2,R> Vector<R> |
forEach3(java.util.function.Function<? super T,? extends java.lang.Iterable<R1>> iterable1,
java.util.function.BiFunction<? super T,? super R1,? extends java.lang.Iterable<R2>> iterable2,
Function3<? super T,? super R1,? super R2,java.lang.Boolean> filterFunction,
Function3<? super T,? super R1,? super R2,? extends R> yieldingFunction) |
<R1,R2,R3,R> |
forEach4(java.util.function.Function<? super T,? extends java.lang.Iterable<R1>> iterable1,
java.util.function.BiFunction<? super T,? super R1,? extends java.lang.Iterable<R2>> iterable2,
Function3<? super T,? super R1,? super R2,? extends java.lang.Iterable<R3>> iterable3,
Function4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction) |
<R1,R2,R3,R> |
forEach4(java.util.function.Function<? super T,? extends java.lang.Iterable<R1>> iterable1,
java.util.function.BiFunction<? super T,? super R1,? extends java.lang.Iterable<R2>> iterable2,
Function3<? super T,? super R1,? super R2,? extends java.lang.Iterable<R3>> iterable3,
Function4<? super T,? super R1,? super R2,? super R3,java.lang.Boolean> filterFunction,
Function4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction) |
static <T> Vector<T> |
fromIterable(java.lang.Iterable<T> it) |
static <T> Vector<T> |
fromIterator(java.util.Iterator<T> it) |
static <T> Vector<T> |
fromStream(java.util.stream.Stream<T> it) |
static <T> Vector<T> |
generate(Generator<T> s) |
static <T> Vector<T> |
generate(java.util.function.Supplier<T> s,
int max) |
Option<T> |
get(int pos) |
T |
getOrElse(int pos,
T alt) |
T |
getOrElseGet(int pos,
java.util.function.Supplier<? extends T> alt) |
Vector<Vector<T>> |
grouped(int groupSize)
Group elements in a Stream
|
<C extends PersistentCollection<? super T>> |
grouped(int size,
java.util.function.Supplier<C> supplier)
Group the elements of this traversable
|
Vector<Vector<T>> |
groupedUntil(java.util.function.BiPredicate<Vector<? super T>,? super T> predicate)
Create Travesable of Lists where
each List is populated while the supplied bipredicate holds.
|
Vector<Vector<T>> |
groupedUntil(java.util.function.Predicate<? super T> predicate)
ReactiveSeq.of(1,2,3,4,5,6)
.groupedUntil(i->i%3==0)
.toList()
.size();
//2
|
<C extends PersistentCollection<? super T>> |
groupedUntil(java.util.function.Predicate<? super T> predicate,
java.util.function.Supplier<C> factory)
Create a ReactiveSeq batched by a Collection, where each batch is populated
until the predicate holds
|
Vector<Vector<T>> |
groupedWhile(java.util.function.Predicate<? super T> predicate)
Create a Traversable batched by List, where each batch is populated while
the predicate holds
|
<C extends PersistentCollection<? super T>> |
groupedWhile(java.util.function.Predicate<? super T> predicate,
java.util.function.Supplier<C> factory)
Create a SequenceM batched by a Collection, where each batch is populated
while the predicate holds
|
int |
hashCode() |
Vector<T> |
insertAt(int pos,
java.lang.Iterable<? extends T> values) |
Vector<T> |
insertAt(int pos,
ReactiveSeq<? extends T> values) |
Vector<T> |
insertAt(int pos,
T... values)
Insert data into a traversable at given position
|
Vector<T> |
insertAt(int i,
T e) |
Vector<T> |
insertStreamAt(int pos,
java.util.stream.Stream<T> stream)
Insert a Stream into the middle of this traversable at the specified position
|
Vector<T> |
intersperse(T value)
Returns a Traversable with a given value interspersed between any two values.
|
boolean |
isEmpty() |
static <T> Vector<T> |
iterate(T seed,
java.util.function.Predicate<? super T> pred,
java.util.function.UnaryOperator<T> f) |
static <T> Vector<T> |
iterate(T seed,
java.util.function.UnaryOperator<T> f,
int max) |
java.util.Iterator<T> |
iterator() |
<R> Vector<R> |
map(java.util.function.Function<? super T,? extends R> fn)
Transform this functor using the supplied transformation function
|
<R> Vector<R> |
mergeMap(java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> fn) |
<R> Vector<R> |
mergeMap(int maxConcurecy,
java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> fn) |
static <T> Vector<T> |
narrowK(Higher<DataWitness.vector,T> list) |
Vector<T> |
notNull()
Filter elements retaining only values which are not null
|
static <T> Vector<T> |
of(T... value) |
<U> Vector<U> |
ofType(java.lang.Class<? extends U> type)
Keep only those elements in a stream that are of a given type.
|
Vector<T> |
onEmpty(T value)
If this Container instance is zero, create a new instance containing the provided value
|
Vector<T> |
onEmptyGet(java.util.function.Supplier<? extends T> supplier)
If this Container instance is zero, create a new instance containing the value returned from the provided Supplier
|
ImmutableList<T> |
onEmptySwitch(java.util.function.Supplier<? extends ImmutableList<T>> supplier)
Switch to container created by provided Supplier, if current Container zero
|
Vector<T> |
peek(java.util.function.Consumer<? super T> c)
Peek at the current value of this Transformable, without transforming it
|
Vector<ReactiveSeq<T>> |
permutations() |
Vector<T> |
plus(T t) |
Vector<T> |
plusAll(int i,
java.lang.Iterable<? extends T> values) |
Vector<T> |
plusAll(java.lang.Iterable<? extends T> list) |
Vector<T> |
prepend(T value) |
Vector<T> |
prependAll(java.lang.Iterable<? extends T> value) |
Vector<T> |
prependAll(T... values)
List<String> result = ReactiveSeq.of(1,2,3)
.prependAll(100,200,300)
.map(it ->it+"!!")
.collect(CyclopsCollectors.toList());
//asList("100!!","200!!","300!!","1!!","2!!","3!!")));
|
Vector<T> |
prependStream(java.util.stream.Stream<? extends T> stream) |
static Vector<java.lang.Integer> |
range(int start,
int end) |
static Vector<java.lang.Integer> |
range(int start,
int step,
int end) |
static Vector<java.lang.Long> |
rangeLong(long start,
long end) |
static Vector<java.lang.Long> |
rangeLong(long start,
long step,
long end) |
Vector<T> |
removeAll(java.lang.Iterable<? extends T> list)
Remove all elements in the supplied Iterable from this filterable
|
Vector<T> |
removeAt(int i) |
Vector<T> |
removeAt(long pos) |
Vector<T> |
removeFirst(java.util.function.Predicate<? super T> pred) |
Vector<T> |
removeStream(java.util.stream.Stream<? extends T> stream)
Remove all elements in the supplied Stream from this filterable
|
Vector<T> |
removeValue(T e) |
Vector<T> |
replaceFirst(T currentElement,
T newElement) |
Vector<T> |
retainAll(java.lang.Iterable<? extends T> it)
Retain only the supplied elements in the returned Filters
|
Vector<T> |
retainAll(T... values)
Retain only the supplied elements in the returned Filters
|
Vector<T> |
retainStream(java.util.stream.Stream<? extends T> stream)
Retain only the supplied elements in the returned Filters
|
ImmutableList<T> |
reverse() |
Vector<T> |
scanLeft(Monoid<T> monoid)
Scan left using supplied Monoid
|
<U> Vector<U> |
scanLeft(U seed,
java.util.function.BiFunction<? super U,? super T,? extends U> function)
Scan left
|
Vector<T> |
scanRight(Monoid<T> monoid)
Scan right
|
<U> Vector<U> |
scanRight(U identity,
java.util.function.BiFunction<? super T,? super U,? extends U> combiner)
Scan right
|
Either<java.lang.Integer,Vector<T>> |
set(int pos,
T value) |
Vector<T> |
shuffle() |
Vector<T> |
shuffle(java.util.Random random) |
int |
size() |
Vector<T> |
slice(long from,
long to) |
Vector<Seq<T>> |
sliding(int windowSize)
Create a sliding view
|
Vector<Seq<T>> |
sliding(int windowSize,
int increment)
Create a sliding view
|
Vector<T> |
sorted()
{@code ReactiveSeq.of(4,3,6,7))
.sorted()
.toList()
//Arrays.asList(3,4,6,7)
|
Vector<T> |
sorted(java.util.Comparator<? super T> c)
assertThat(ReactiveSeq.of(4,3,6,7).sorted((a,b) -> b-a).toList(),equalTo(Arrays.asList(7,6,4,3)));
|
<U extends java.lang.Comparable<? super U>> |
sorted(java.util.function.Function<? super T,? extends U> function) |
ReactiveSeq<T> |
stream() |
Vector<T> |
subList(int start,
int end) |
static <T,R> Vector<R> |
tailRec(T initial,
java.util.function.Function<? super T,? extends Vector<? extends Either<T,R>>> fn) |
Vector<T> |
take(long num)
{@code
ReactiveSeq.of(4,3,6,7)
.take(2)
.toList()
asList(4,3)
|
Vector<T> |
takeRight(int num)
Generate a new Traversable that takes the specified number elements from the take of this Traversable
|
Vector<T> |
takeUntil(java.util.function.Predicate<? super T> p)
Generate a new Traversable that takes elements from this Traversable until the predicate holds
|
Vector<T> |
takeWhile(java.util.function.Predicate<? super T> p)
Generate a new Traversable that takes elements from this Traversable as long as the predicate holds
|
java.lang.String |
toString() |
static <U,T> Vector<T> |
unfold(U seed,
java.util.function.Function<? super U,Option<Tuple2<T,U>>> unfolder) |
<R> Vector<R> |
unitIterable(java.lang.Iterable<R> it) |
<R> Vector<R> |
unitStream(java.util.stream.Stream<R> stream) |
static <T,U> Tuple2<Vector<T>,Vector<U>> |
unzip(Vector<Tuple2<T,U>> sequence) |
Vector<T> |
updateAt(int pos,
T value) |
static <T> Higher<DataWitness.vector,T> |
widen(Vector<T> narrow) |
static <C2,T> Higher<C2,Higher<DataWitness.vector,T>> |
widen2(Higher<C2,Vector<T>> list) |
<T2,R> Vector<R> |
zip(java.util.function.BiFunction<? super T,? super T2,? extends R> fn,
org.reactivestreams.Publisher<? extends T2> publisher)
Zip (combine) this Zippable with the supplied Publisher, using the supplied combining function
|
<U> Vector<Tuple2<T,U>> |
zip(java.lang.Iterable<? extends U> other) |
<U,R> Vector<R> |
zip(java.lang.Iterable<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
Zip (combine) this Zippable with the supplied Iterable using the supplied combining function
|
<S,U> Vector<Tuple3<T,S,U>> |
zip3(java.lang.Iterable<? extends S> second,
java.lang.Iterable<? extends U> third) |
<S,U,R> Vector<R> |
zip3(java.lang.Iterable<? extends S> second,
java.lang.Iterable<? extends U> third,
Function3<? super T,? super S,? super U,? extends R> fn3) |
<T2,T3,T4> Vector<Tuple4<T,T2,T3,T4>> |
zip4(java.lang.Iterable<? extends T2> second,
java.lang.Iterable<? extends T3> third,
java.lang.Iterable<? extends T4> fourth) |
<T2,T3,T4,R> |
zip4(java.lang.Iterable<? extends T2> second,
java.lang.Iterable<? extends T3> third,
java.lang.Iterable<? extends T4> fourth,
Function4<? super T,? super T2,? super T3,? super T4,? extends R> fn) |
Vector<Tuple2<T,java.lang.Long>> |
zipWithIndex() |
<U> Vector<Tuple2<T,U>> |
zipWithPublisher(org.reactivestreams.Publisher<? extends U> other) |
<U> Vector<Tuple2<T,U>> |
zipWithStream(java.util.stream.Stream<? extends U> other) |
<U,R> Vector<R> |
zipWithStream(java.util.stream.Stream<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends R> zipper) |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
compareTo, equalToDirectAccess, focusAt, focusAt, fold, last, lazySeq, nonEmptyList, onEmptyTry, partition, removeAll, seq, span, splitAt, splitBy, tailOrElse, traversable
asFunction, equalToIteration, foldFuture, foldLazy, foldTry, forEach, forEach, forEach, forEach, forEach, forEachSubscribe, forEachSubscribe, forEachSubscribe, runFuture, runLazy, to, toHashSet
fixedDelay, onePer, subscribe, xPer
allMatch, anyMatch, atPercentile, bankersQueue, collect, collect, collect, collect, count, countDistinct, doubleStats, elementAt, endsWith, firstValue, foldLeft, foldLeft, foldLeft, foldLeft, foldLeft, foldLeft, foldMap, foldMap, foldMapRight, foldRight, foldRight, foldRight, groupBy, hashSet, headOption, indexOf, indexOfSlice, intStats, iterableTo, join, join, join, lastIndexOf, lastIndexOfSlice, longStats, maxBy, maxBy, maximum, mean, median, minBy, minBy, minimum, mode, noneMatch, nonEmptyList, occurances, populationVariance, print, print, printErr, printOut, scheduleStream, single, single, singleOrElse, startsWith, stdDeviation, sumDouble, sumInt, sumLong, takeOne, toArray, toArray, toCollection, toHashMap, toHashMap, toList, toMap, toMap, toSet, treeSet, variance, vector, withPercentiles, xMatch
listView
public Vector(BAMT.NestedArray<T> root, BAMT.ActiveTail<T> tail, int size)
public Vector<T> plusAll(java.lang.Iterable<? extends T> list)
plusAll
in interface PersistentCollection<T>
plusAll
in interface PersistentList<T>
plusAll
in interface IterableX<T>
plusAll
in interface ImmutableList<T>
public boolean containsValue(T value)
containsValue
in interface PersistentCollection<T>
containsValue
in interface IterableX<T>
containsValue
in interface ImmutableList<T>
public <R> Vector<R> unitIterable(java.lang.Iterable<R> it)
unitIterable
in interface IterableX<T>
unitIterable
in interface Traversable<T>
unitIterable
in interface ImmutableList<T>
public static <T> Vector<T> narrowK(Higher<DataWitness.vector,T> list)
public static <C2,T> Higher<C2,Higher<DataWitness.vector,T>> widen2(Higher<C2,Vector<T>> list)
public <R1,R2,R3,R> Vector<R> forEach4(java.util.function.Function<? super T,? extends java.lang.Iterable<R1>> iterable1, java.util.function.BiFunction<? super T,? super R1,? extends java.lang.Iterable<R2>> iterable2, Function3<? super T,? super R1,? super R2,? extends java.lang.Iterable<R3>> iterable3, Function4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
forEach4
in interface ImmutableList<T>
public <R1,R2,R3,R> Vector<R> forEach4(java.util.function.Function<? super T,? extends java.lang.Iterable<R1>> iterable1, java.util.function.BiFunction<? super T,? super R1,? extends java.lang.Iterable<R2>> iterable2, Function3<? super T,? super R1,? super R2,? extends java.lang.Iterable<R3>> iterable3, Function4<? super T,? super R1,? super R2,? super R3,java.lang.Boolean> filterFunction, Function4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
forEach4
in interface ImmutableList<T>
public <R1,R2,R> Vector<R> forEach3(java.util.function.Function<? super T,? extends java.lang.Iterable<R1>> iterable1, java.util.function.BiFunction<? super T,? super R1,? extends java.lang.Iterable<R2>> iterable2, Function3<? super T,? super R1,? super R2,? extends R> yieldingFunction)
forEach3
in interface ImmutableList<T>
public <R1,R2,R> Vector<R> forEach3(java.util.function.Function<? super T,? extends java.lang.Iterable<R1>> iterable1, java.util.function.BiFunction<? super T,? super R1,? extends java.lang.Iterable<R2>> iterable2, Function3<? super T,? super R1,? super R2,java.lang.Boolean> filterFunction, Function3<? super T,? super R1,? super R2,? extends R> yieldingFunction)
forEach3
in interface ImmutableList<T>
public <R1,R> Vector<R> forEach2(java.util.function.Function<? super T,? extends java.lang.Iterable<R1>> iterable1, java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction)
forEach2
in interface ImmutableList<T>
public <R1,R> Vector<R> forEach2(java.util.function.Function<? super T,? extends java.lang.Iterable<R1>> iterable1, java.util.function.BiFunction<? super T,? super R1,java.lang.Boolean> filterFunction, java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction)
forEach2
in interface ImmutableList<T>
public java.util.Iterator<T> iterator()
iterator
in interface ImmutableList<T>
iterator
in interface java.lang.Iterable<T>
public Vector<T> removeValue(T e)
removeValue
in interface PersistentCollection<T>
removeValue
in interface PersistentList<T>
removeValue
in interface IterableX<T>
removeValue
in interface ImmutableList<T>
public Vector<T> removeAll(java.lang.Iterable<? extends T> list)
IterableFilterable
removeAll
in interface PersistentCollection<T>
removeAll
in interface PersistentList<T>
removeAll
in interface IterableFilterable<T>
removeAll
in interface IterableX<T>
removeAll
in interface ImmutableList<T>
list
- an Iterable of elements to removeValuepublic Vector<T> removeAt(int i)
removeAt
in interface PersistentList<T>
removeAt
in interface IterableX<T>
removeAt
in interface Traversable<T>
removeAt
in interface ImmutableList<T>
public Vector<T> removeAt(long pos)
removeAt
in interface IterableX<T>
removeAt
in interface Traversable<T>
removeAt
in interface ImmutableList<T>
public Vector<T> insertAt(int pos, T... values)
Traversable
List<String> result = ReactiveSeq.of(1, 2, 3)
.insertAt(1, 100, 200, 300)
.map(it -> it + "!!")
.collect(CyclopsCollectors.toList());
//Arrays.asList("1!!", "100!!", "200!!", "300!!", "2!!", "3!!")))
insertAt
in interface IterableX<T>
insertAt
in interface Traversable<T>
insertAt
in interface ImmutableList<T>
pos
- to insert data atvalues
- to insertpublic Vector<T> insertAt(int i, T e)
insertAt
in interface PersistentList<T>
insertAt
in interface IterableX<T>
insertAt
in interface ImmutableList<T>
public Vector<T> insertAt(int pos, java.lang.Iterable<? extends T> values)
insertAt
in interface PersistentList<T>
insertAt
in interface IterableX<T>
insertAt
in interface Traversable<T>
insertAt
in interface ImmutableList<T>
public Vector<T> insertAt(int pos, ReactiveSeq<? extends T> values)
insertAt
in interface Traversable<T>
public static <T> Vector<T> empty()
public static <T> Vector<T> fill(T t, int max)
public static <U,T> Vector<T> unfold(U seed, java.util.function.Function<? super U,Option<Tuple2<T,U>>> unfolder)
public static <T> Vector<T> iterate(T seed, java.util.function.Predicate<? super T> pred, java.util.function.UnaryOperator<T> f)
public static <T> Vector<T> iterate(T seed, java.util.function.UnaryOperator<T> f, int max)
public static <T> Vector<T> generate(java.util.function.Supplier<T> s, int max)
public static Vector<java.lang.Integer> range(int start, int end)
public static Vector<java.lang.Integer> range(int start, int step, int end)
public static Vector<java.lang.Long> rangeLong(long start, long step, long end)
public static Vector<java.lang.Long> rangeLong(long start, long end)
public static <T> Vector<T> fromStream(java.util.stream.Stream<T> it)
public static <T> Vector<T> fromIterator(java.util.Iterator<T> it)
public static <T> Vector<T> fromIterable(java.lang.Iterable<T> it)
public static <T> Vector<T> of(T... value)
public Vector<T> removeFirst(java.util.function.Predicate<? super T> pred)
removeFirst
in interface IterableX<T>
removeFirst
in interface Traversable<T>
removeFirst
in interface ImmutableList<T>
public ReactiveSeq<T> stream()
stream
in interface Folds<T>
stream
in interface PersistentCollection<T>
stream
in interface IterableX<T>
stream
in interface Traversable<T>
stream
in interface ImmutableList<T>
public Vector<T> filter(java.util.function.Predicate<? super T> pred)
Filters
of(1,2,3).filter(i->i>2);
//[3]
filter
in interface Filters<T>
filter
in interface FilterableTransformable<T>
filter
in interface IterableX<T>
filter
in interface ImmutableList<T>
pred
- to filter elements by, retaining matchespublic <R> Vector<R> map(java.util.function.Function<? super T,? extends R> fn)
Transformable
of(1,2,3).map(i->i*2)
//[2,4,6]
map
in interface FilterableTransformable<T>
map
in interface Transformable<T>
map
in interface IterableX<T>
map
in interface Traversable<T>
map
in interface ImmutableList<T>
fn
- Transformation functionpublic <R> R fold(java.util.function.Function<? super ImmutableList.Some<T>,? extends R> fn1, java.util.function.Function<? super ImmutableList.None<T>,? extends R> fn2)
fold
in interface Sealed2<ImmutableList.Some<T>,ImmutableList.None<T>>
fold
in interface ImmutableList<T>
public Vector<T> onEmpty(T value)
OnEmpty
public Vector<T> onEmptyGet(java.util.function.Supplier<? extends T> supplier)
OnEmpty
onEmptyGet
in interface OnEmpty<T>
onEmptyGet
in interface IterableX<T>
onEmptyGet
in interface Traversable<T>
onEmptyGet
in interface ImmutableList<T>
supplier
- to determine new value for containerpublic Vector<T> replaceFirst(T currentElement, T newElement)
replaceFirst
in interface ImmutableList<T>
public <U> Vector<U> ofType(java.lang.Class<? extends U> type)
Filters
// (1, 2, 3) ReactiveSeq.of(1, "a", 2, "b",3).ofType(Integer.class)
public Vector<T> filterNot(java.util.function.Predicate<? super T> predicate)
Filters
of(1,2,3).filter(i->i>2);
//[1,2]
filterNot
in interface Filters<T>
filterNot
in interface IterableX<T>
filterNot
in interface Traversable<T>
filterNot
in interface ImmutableList<T>
predicate
- to filter elements by, retaining matchespublic Vector<T> notNull()
Filters
of(1,2,null,4).nonNull();
//[1,2,4]
public Vector<T> peek(java.util.function.Consumer<? super T> c)
Transformable
of(1,2,3).map(System.out::println)
1
2
3
peek
in interface Transformable<T>
peek
in interface IterableX<T>
peek
in interface ImmutableList<T>
c
- Consumer that recieves each element from this Transformablepublic Vector<T> removeStream(java.util.stream.Stream<? extends T> stream)
IterableFilterable
removeStream
in interface IterableFilterable<T>
removeStream
in interface IterableX<T>
removeStream
in interface ImmutableList<T>
stream
- of elements to removepublic Vector<T> retainAll(java.lang.Iterable<? extends T> it)
IterableFilterable
retainAll
in interface IterableFilterable<T>
retainAll
in interface IterableX<T>
retainAll
in interface ImmutableList<T>
it
- Iterable of elements to retainpublic Vector<T> retainStream(java.util.stream.Stream<? extends T> stream)
IterableFilterable
retainStream
in interface IterableFilterable<T>
retainStream
in interface IterableX<T>
retainStream
in interface ImmutableList<T>
stream
- of elements to retainpublic Vector<T> retainAll(T... values)
IterableFilterable
retainAll
in interface IterableFilterable<T>
retainAll
in interface IterableX<T>
retainAll
in interface ImmutableList<T>
values
- elements to retainpublic Vector<ReactiveSeq<T>> permutations()
permutations
in interface IterableX<T>
permutations
in interface ImmutableList<T>
public Vector<ReactiveSeq<T>> combinations(int size)
combinations
in interface IterableX<T>
combinations
in interface ImmutableList<T>
public Vector<ReactiveSeq<T>> combinations()
combinations
in interface IterableX<T>
combinations
in interface ImmutableList<T>
public <T2,R> Vector<R> zip(java.util.function.BiFunction<? super T,? super T2,? extends R> fn, org.reactivestreams.Publisher<? extends T2> publisher)
Zippable
public <U,R> Vector<R> zipWithStream(java.util.stream.Stream<? extends U> other, java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
zipWithStream
in interface IterableX<T>
zipWithStream
in interface Traversable<T>
zipWithStream
in interface ImmutableList<T>
public <U> Vector<Tuple2<T,U>> zipWithPublisher(org.reactivestreams.Publisher<? extends U> other)
zipWithPublisher
in interface IterableX<T>
zipWithPublisher
in interface Traversable<T>
zipWithPublisher
in interface Zippable<T>
zipWithPublisher
in interface ImmutableList<T>
public <S,U,R> Vector<R> zip3(java.lang.Iterable<? extends S> second, java.lang.Iterable<? extends U> third, Function3<? super T,? super S,? super U,? extends R> fn3)
public <T2,T3,T4,R> Vector<R> zip4(java.lang.Iterable<? extends T2> second, java.lang.Iterable<? extends T3> third, java.lang.Iterable<? extends T4> fourth, Function4<? super T,? super T2,? super T3,? super T4,? extends R> fn)
public Vector<T> combine(java.util.function.BiPredicate<? super T,? super T> predicate, java.util.function.BinaryOperator<T> op)
Traversable
ReactiveSeq.of(1,1,2,3)
.combine((a, b)->a.equals(b),SemigroupK.intSum)
.listX()
//Seq(3,4)
Can be used to implement terminating lazy folds on lazy data types
ReactiveSeq.generate(this::process)
.map(data->data.isSuccess())
.combine((a,b)-> a ? false : true, (a,b) -> a|b)
.findFirst(); //terminating reduction on infinite data structure
combine
in interface IterableX<T>
combine
in interface Traversable<T>
combine
in interface ImmutableList<T>
predicate
- Test to see if two neighbours should be joined. The first parameter to the bi-predicate is the currently
accumulated result and the second is the next elementop
- BinaryOperator to combine neighbourspublic Vector<T> combine(Monoid<T> op, java.util.function.BiPredicate<? super T,? super T> predicate)
Traversable
ReactiveSeq.of(1,1,2,3)
.combine(Monoids.intMult,(a, b)->a.equals(b))
.listX()
//Seq(1)
Simalar to @see Traversable.combine(BiPredicate, BinaryOperator)
but differs in that the first comparison is always to the Monoid zero
This allows us to terminate with just a single valuecombine
in interface IterableX<T>
combine
in interface Traversable<T>
combine
in interface ImmutableList<T>
op
- Monoid to combine neighbourspredicate
- Test to see if two neighbours should be joined. The first parameter to the bi-predicate is the currently
accumulated result and the second is the next elementpublic Vector<T> cycle(long times)
cycle
in interface IterableX<T>
cycle
in interface Traversable<T>
cycle
in interface ImmutableList<T>
public Vector<T> cycle(Monoid<T> m, long times)
cycle
in interface IterableX<T>
cycle
in interface Traversable<T>
cycle
in interface ImmutableList<T>
public Vector<T> cycleWhile(java.util.function.Predicate<? super T> predicate)
cycleWhile
in interface IterableX<T>
cycleWhile
in interface Traversable<T>
cycleWhile
in interface ImmutableList<T>
public Vector<T> cycleUntil(java.util.function.Predicate<? super T> predicate)
cycleUntil
in interface IterableX<T>
cycleUntil
in interface Traversable<T>
cycleUntil
in interface ImmutableList<T>
public <U,R> Vector<R> zip(java.lang.Iterable<? extends U> other, java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
Zippable
public <S,U> Vector<Tuple3<T,S,U>> zip3(java.lang.Iterable<? extends S> second, java.lang.Iterable<? extends U> third)
public <T2,T3,T4> Vector<Tuple4<T,T2,T3,T4>> zip4(java.lang.Iterable<? extends T2> second, java.lang.Iterable<? extends T3> third, java.lang.Iterable<? extends T4> fourth)
public Vector<Tuple2<T,java.lang.Long>> zipWithIndex()
zipWithIndex
in interface IterableX<T>
zipWithIndex
in interface Traversable<T>
zipWithIndex
in interface ImmutableList<T>
public Vector<Seq<T>> sliding(int windowSize)
Traversable
sliding
in interface IterableX<T>
sliding
in interface Traversable<T>
sliding
in interface ImmutableList<T>
public Vector<Seq<T>> sliding(int windowSize, int increment)
Traversable
sliding
in interface IterableX<T>
sliding
in interface Traversable<T>
sliding
in interface ImmutableList<T>
public <C extends PersistentCollection<? super T>> Vector<C> grouped(int size, java.util.function.Supplier<C> supplier)
Traversable
ReactiveSeq.of(1,1,1,1,1,1)
.grouped(3,()->new TreeSet<>())
.toList()
.getValue(0)
.size();
//1
ReactiveSeq.of(1,2,3,4,5,6)
.grouped(3,()->new TreeSet<>())
.toList()
.getValue(0)
.size();
//3
grouped
in interface IterableX<T>
grouped
in interface Traversable<T>
grouped
in interface ImmutableList<T>
size
- batch sizesupplier
- Collection factorypublic Vector<Vector<T>> groupedUntil(java.util.function.Predicate<? super T> predicate)
Traversable
ReactiveSeq.of(1,2,3,4,5,6)
.groupedUntil(i->i%3==0)
.toList()
.size();
//2
groupedUntil
in interface IterableX<T>
groupedUntil
in interface Traversable<T>
groupedUntil
in interface ImmutableList<T>
predicate
- group until predicate holdspublic Vector<Vector<T>> groupedUntil(java.util.function.BiPredicate<Vector<? super T>,? super T> predicate)
Traversable
assertThat(ReactiveSeq.of(1,2,3,4,5,6)
.groupedUntil((s,i)->s.contains(4) ? true : false)
.toList().size(),equalTo(5));
groupedUntil
in interface IterableX<T>
groupedUntil
in interface Traversable<T>
groupedUntil
in interface ImmutableList<T>
predicate
- Window while truepublic <U> Vector<Tuple2<T,U>> zipWithStream(java.util.stream.Stream<? extends U> other)
zipWithStream
in interface IterableX<T>
zipWithStream
in interface Traversable<T>
zipWithStream
in interface ImmutableList<T>
public Vector<Vector<T>> groupedWhile(java.util.function.Predicate<? super T> predicate)
Traversable
assertThat(ReactiveSeq.of(1,2,3,4,5,6)
.groupedWhile(i->i%3!=0)
.toList().size(),equalTo(2));
groupedWhile
in interface IterableX<T>
groupedWhile
in interface Traversable<T>
groupedWhile
in interface ImmutableList<T>
predicate
- Batch while predicate holds, applyHKT open next batchpublic <C extends PersistentCollection<? super T>> Vector<C> groupedWhile(java.util.function.Predicate<? super T> predicate, java.util.function.Supplier<C> factory)
Traversable
assertThat(ReactiveSeq.of(1,2,3,4,5,6)
.groupedWhile(i->i%3!=0)
.toList()
.size(),equalTo(2));
groupedWhile
in interface IterableX<T>
groupedWhile
in interface Traversable<T>
groupedWhile
in interface ImmutableList<T>
predicate
- Batch while predicate holds, applyHKT open next batchfactory
- Collection factorypublic <C extends PersistentCollection<? super T>> Vector<C> groupedUntil(java.util.function.Predicate<? super T> predicate, java.util.function.Supplier<C> factory)
Traversable
ReactiveSeq.of(1,2,3,4,5,6)
.groupedUntil(i->i%3!=0)
.toList()
//2
groupedUntil
in interface IterableX<T>
groupedUntil
in interface Traversable<T>
groupedUntil
in interface ImmutableList<T>
predicate
- Batch until predicate holds, applyHKT open next batchfactory
- Collection factorypublic Vector<Vector<T>> grouped(int groupSize)
Traversable
List<List<Integer>> list = ReactiveSeq.of(1, 2, 3, 4, 5, 6).grouped(3).collect(CyclopsCollectors.toList());
assertThat(list.getValue(0), hasItems(1, 2, 3));
assertThat(list.getValue(1), hasItems(4, 5, 6));
grouped
in interface IterableX<T>
grouped
in interface Traversable<T>
grouped
in interface ImmutableList<T>
groupSize
- Size of each Grouppublic Vector<T> distinct()
distinct
in interface IterableX<T>
distinct
in interface Traversable<T>
distinct
in interface ImmutableList<T>
public Vector<T> scanLeft(Monoid<T> monoid)
Traversable
{@code ReactiveSeq.of("a", "b", "c") .scanLeft(Reducers.toString("")) .toList(); //asList("", "a", "ab", "abc")
scanLeft
in interface IterableX<T>
scanLeft
in interface Traversable<T>
scanLeft
in interface ImmutableList<T>
public <U> Vector<U> scanLeft(U seed, java.util.function.BiFunction<? super U,? super T,? extends U> function)
Traversable
ReactiveSeq.of("a", "b", "c")
.scanLeft("", String::concat)
.toList();
//[, a, ab, abc]
scanLeft
in interface IterableX<T>
scanLeft
in interface Traversable<T>
scanLeft
in interface ImmutableList<T>
public Vector<T> scanRight(Monoid<T> monoid)
Traversable
ReactiveSeq.of("a", "b", "c")
.scanRight(Monoid.of("", String::concat))
.toList()
//asList("", "c", "bc", "abc")
scanRight
in interface IterableX<T>
scanRight
in interface Traversable<T>
scanRight
in interface ImmutableList<T>
public <U> Vector<U> scanRight(U identity, java.util.function.BiFunction<? super T,? super U,? extends U> combiner)
Traversable
ReactiveSeq.of("a", "ab", "abc")
.map(str->str.length())
.scanRight(0, (t, u) -> u + t)
.toList();
//asList(0, 3, 5, 6);
scanRight
in interface IterableX<T>
scanRight
in interface Traversable<T>
scanRight
in interface ImmutableList<T>
public Vector<T> sorted()
Traversable
{@code ReactiveSeq.of(4,3,6,7)) .sorted() .toList() //Arrays.asList(3,4,6,7)
sorted
in interface IterableX<T>
sorted
in interface Traversable<T>
sorted
in interface ImmutableList<T>
public Vector<T> sorted(java.util.Comparator<? super T> c)
Traversable
assertThat(ReactiveSeq.of(4,3,6,7).sorted((a,b) -> b-a).toList(),equalTo(Arrays.asList(7,6,4,3)));
sorted
in interface IterableX<T>
sorted
in interface Traversable<T>
sorted
in interface ImmutableList<T>
c
- Compartor to sort withpublic Vector<T> takeWhile(java.util.function.Predicate<? super T> p)
Traversable
Seq.of(1,2,3).takeWhile(i<3);
//[1,2]
takeWhile
in interface IterableX<T>
takeWhile
in interface Traversable<T>
takeWhile
in interface ImmutableList<T>
p
- Predicate to determine when values should be takenpublic Vector<T> dropWhile(java.util.function.Predicate<? super T> p)
Traversable
Seq.of(1,2,3).dropWhile(i<3);
//[3]
dropWhile
in interface IterableX<T>
dropWhile
in interface Traversable<T>
dropWhile
in interface ImmutableList<T>
p
- Predicate to determine when values should be droppedpublic Vector<T> takeUntil(java.util.function.Predicate<? super T> p)
Traversable
Seq.of(1,2,3).takeUntil(i<2);
//[1,2]
takeUntil
in interface IterableX<T>
takeUntil
in interface Traversable<T>
takeUntil
in interface ImmutableList<T>
p
- Predicate to determine when values should be taken untilpublic Vector<T> dropUntil(java.util.function.Predicate<? super T> p)
Traversable
Seq.of(1,2,3).dropUntil(i>2);
//[3]
dropUntil
in interface IterableX<T>
dropUntil
in interface Traversable<T>
dropUntil
in interface ImmutableList<T>
p
- Predicate to determine when values should be droppedpublic Vector<T> intersperse(T value)
Traversable
ReactiveSeq.of(1, 2, 3, 4).intersperse(0)
// (1, 0, 2, 0, 3, 0, 4)
intersperse
in interface IterableX<T>
intersperse
in interface Traversable<T>
intersperse
in interface ImmutableList<T>
public Vector<T> shuffle()
shuffle
in interface IterableX<T>
shuffle
in interface Traversable<T>
shuffle
in interface ImmutableList<T>
public Vector<T> shuffle(java.util.Random random)
shuffle
in interface IterableX<T>
shuffle
in interface Traversable<T>
shuffle
in interface ImmutableList<T>
public Vector<T> slice(long from, long to)
slice
in interface IterableX<T>
slice
in interface Traversable<T>
slice
in interface ImmutableList<T>
public Vector<T> prependStream(java.util.stream.Stream<? extends T> stream)
prependStream
in interface IterableX<T>
prependStream
in interface Traversable<T>
prependStream
in interface ImmutableList<T>
public Vector<T> appendAll(T... values)
appendAll
in interface IterableX<T>
appendAll
in interface Traversable<T>
appendAll
in interface ImmutableList<T>
public Vector<T> prependAll(T... values)
Traversable
List<String> result = ReactiveSeq.of(1,2,3)
.prependAll(100,200,300)
.map(it ->it+"!!")
.collect(CyclopsCollectors.toList());
//asList("100!!","200!!","300!!","1!!","2!!","3!!")));
prependAll
in interface IterableX<T>
prependAll
in interface Traversable<T>
prependAll
in interface ImmutableList<T>
values
- to prependAllpublic Vector<T> deleteBetween(int start, int end)
Traversable
{@code Listresult = ReactiveSeq.of(1, 2, 3, 4, 5, 6) .deleteBetween(2, 4).map(it -> it + "!!") .collect(CyclopsCollectors.toList()); //Arrays.asList("1!!", "2!!", "5!!", "6!!")));
deleteBetween
in interface IterableX<T>
deleteBetween
in interface Traversable<T>
deleteBetween
in interface ImmutableList<T>
start
- indexend
- indexpublic Vector<T> insertStreamAt(int pos, java.util.stream.Stream<T> stream)
Traversable
List<String> result = ReactiveSeq.of(1, 2, 3)
.insertAt(1, of(100, 200, 300))
.map(it -> it + "!!")
.collect(CyclopsCollectors.toList());
//Arrays.asList("1!!", "100!!", "200!!", "300!!", "2!!", "3!!")));
insertStreamAt
in interface IterableX<T>
insertStreamAt
in interface Traversable<T>
insertStreamAt
in interface ImmutableList<T>
pos
- to insert Stream atstream
- to insertpublic <U extends java.lang.Comparable<? super U>> Vector<T> sorted(java.util.function.Function<? super T,? extends U> function)
sorted
in interface IterableX<T>
sorted
in interface Traversable<T>
sorted
in interface ImmutableList<T>
public Vector<T> updateAt(int pos, T value)
updateAt
in interface PersistentList<T>
updateAt
in interface IterableX<T>
updateAt
in interface Traversable<T>
updateAt
in interface ImmutableList<T>
public ImmutableList<T> onEmptySwitch(java.util.function.Supplier<? extends ImmutableList<T>> supplier)
OnEmptySwitch
Seq.zero().onEmptySwitch(()->Seq.of(1));
onEmptySwitch
in interface OnEmptySwitch<ImmutableList<T>,ImmutableList<T>>
onEmptySwitch
in interface ImmutableList<T>
supplier
- to create replacement containerpublic <R> Vector<R> flatMap(java.util.function.Function<? super T,? extends ImmutableList<? extends R>> fn)
flatMap
in interface ImmutableList<T>
public <R> Vector<R> mergeMap(java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> fn)
public <R> Vector<R> mergeMap(int maxConcurecy, java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> fn)
public <R> Vector<R> concatMap(java.util.function.Function<? super T,? extends java.lang.Iterable<? extends R>> fn)
IterableX
public int size()
size
in interface PersistentCollection<T>
size
in interface IterableX<T>
size
in interface ImmutableList<T>
public boolean isEmpty()
isEmpty
in interface PersistentCollection<T>
isEmpty
in interface IterableX<T>
isEmpty
in interface ImmutableList<T>
public Vector<T> plus(T t)
plus
in interface PersistentCollection<T>
plus
in interface PersistentList<T>
plus
in interface IterableX<T>
plus
in interface ImmutableList<T>
public <R> Vector<R> unitStream(java.util.stream.Stream<R> stream)
unitStream
in interface ImmutableList<T>
public Vector<T> emptyUnit()
emptyUnit
in interface ImmutableList<T>
public Vector<T> takeRight(int num)
Traversable
Seq.of(1,2,3).takeRight(2);
//[2,3]
takeRight
in interface IterableX<T>
takeRight
in interface Traversable<T>
takeRight
in interface ImmutableList<T>
num
- Take this number of elements from the take of this Traversablepublic Vector<T> dropRight(int num)
Traversable
Seq.of(1,2,3).dropRight(2);
//[1]
dropRight
in interface IterableX<T>
dropRight
in interface Traversable<T>
dropRight
in interface ImmutableList<T>
num
- Drop this number of elements from the take of this Traversablepublic Vector<T> drop(long num)
Traversable
assertThat(ReactiveSeq.of(4,3,6,7).drop(2).toList(),equalTo(Arrays.asList(6,7)));
drop
in interface IterableX<T>
drop
in interface Traversable<T>
drop
in interface ImmutableList<T>
num
- Number of elemenets to droppublic Vector<T> take(long num)
Traversable
{@code ReactiveSeq.of(4,3,6,7) .take(2) .toList() asList(4,3)
take
in interface IterableX<T>
take
in interface Traversable<T>
take
in interface ImmutableList<T>
num
- Elements to takepublic Vector<T> prepend(T value)
prepend
in interface IterableX<T>
prepend
in interface Traversable<T>
prepend
in interface ImmutableList<T>
public Vector<T> prependAll(java.lang.Iterable<? extends T> value)
prependAll
in interface IterableX<T>
prependAll
in interface Traversable<T>
prependAll
in interface ImmutableList<T>
public Vector<T> append(T value)
append
in interface IterableX<T>
append
in interface Traversable<T>
append
in interface ImmutableList<T>
public Vector<T> appendAll(java.lang.Iterable<? extends T> value)
appendAll
in interface IterableX<T>
appendAll
in interface Traversable<T>
appendAll
in interface ImmutableList<T>
public Vector<T> subList(int start, int end)
subList
in interface ImmutableList<T>
public ImmutableList<T> reverse()
reverse
in interface IterableX<T>
reverse
in interface Traversable<T>
reverse
in interface ImmutableList<T>
public Option<T> get(int pos)
get
in interface PersistentIndexed<T>
get
in interface ImmutableList<T>
public T getOrElse(int pos, T alt)
getOrElse
in interface PersistentIndexed<T>
getOrElse
in interface ImmutableList<T>
public T getOrElseGet(int pos, java.util.function.Supplier<? extends T> alt)
getOrElseGet
in interface PersistentIndexed<T>
getOrElseGet
in interface ImmutableList<T>
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public static <T,R> Vector<R> tailRec(T initial, java.util.function.Function<? super T,? extends Vector<? extends Either<T,R>>> fn)
public static <T> Higher<DataWitness.vector,T> widen(Vector<T> narrow)