public final class Seq<A>
extends java.lang.Object
implements java.lang.Iterable<A>
| Modifier and Type | Method and Description |
|---|---|
Seq<A> |
append(Seq<A> as)
Appends the given sequence to this sequence.
|
static <A> Seq<A> |
arraySeq(A... as)
Constructs a sequence from the array.
|
<B> Seq<B> |
bind(F<A,Seq<B>> f)
Bind the given function across this seq.
|
Seq<A> |
cons(A a)
Inserts the given element at the front of this sequence.
|
Seq<A> |
delete(int i)
Delete the element at the given index.
|
Seq<A> |
drop(int n)
Drops the given number of elements from the head of this sequence if they are available.
|
static <A> Seq<A> |
empty()
The empty sequence.
|
boolean |
equals(java.lang.Object other) |
Seq<A> |
filter(F<A,java.lang.Boolean> f) |
<B> B |
foldLeft(F2<B,A,B> f,
B z) |
<B> B |
foldRight(F2<A,B,B> f,
B z) |
static <A> Seq<A> |
fromJavaList(java.util.List<A> list)
Constructs a sequence from the given list.
|
int |
hashCode() |
A |
head()
The first element of this sequence.
|
Option<A> |
headOption() |
A |
index(int i)
Returns the element at the given index.
|
Seq<A> |
init()
The sequence without the last element.
|
Seq<A> |
insert(int index,
A a)
Inserts the element at the given index.
|
boolean |
isEmpty()
Checks if this is the empty sequence.
|
boolean |
isNotEmpty()
Checks if this sequence is not empty.
|
static <A> Seq<A> |
iterableSeq(java.lang.Iterable<A> i)
Constructs a sequence from the iterable.
|
java.util.Iterator<A> |
iterator()
Returns an iterator for this seq.
|
static <A> Seq<A> |
iteratorSeq(java.util.Iterator<A> i)
Constructs a sequence from the iterator.
|
A |
last()
The last element of this sequence.
|
int |
length()
Returns the number of elements in this sequence.
|
static <A> Seq<A> |
listSeq(List<A> list)
Constructs a sequence from the given list.
|
<B> Seq<B> |
map(F<A,B> f) |
static <A> Seq<A> |
seq(A... as)
Constructs a sequence from the given elements.
|
static <L,B> Either<L,Seq<B>> |
sequenceEither(Seq<Either<L,B>> seq)
Sequence the given seq and collect the output on the right side of an either.
|
static <R,B> Either<Seq<B>,R> |
sequenceEitherLeft(Seq<Either<B,R>> seq)
Sequence the given seq and collect the output on the left side of an either.
|
static <L,B> Either<L,Seq<B>> |
sequenceEitherRight(Seq<Either<L,B>> seq)
Sequence the given seq and collect the output on the right side of an either.
|
static <C,B> F<C,Seq<B>> |
sequenceF(Seq<F<C,B>> seq)
Sequence the given seq and collect the output as a function.
|
static <B> IO<Seq<B>> |
sequenceIO(Seq<IO<B>> seq)
Sequence the given seq and collect the output as an IO.
|
static <B> List<Seq<B>> |
sequenceList(Seq<List<B>> seq)
Sequence the given seq and collect the output as a list.
|
static <B> Option<Seq<B>> |
sequenceOption(Seq<Option<B>> seq)
Sequence the given seq and collect the output as an seq.
|
static <B> P1<Seq<B>> |
sequenceP1(Seq<P1<B>> seq)
Sequence the given seq and collect the output as a P1.
|
static <B> Seq<Seq<B>> |
sequenceSeq(Seq<Seq<B>> seq)
Sequence the given seq and collect the output as a seq.
|
static <B> Set<Seq<B>> |
sequenceSet(Ord<B> ord,
Seq<Set<B>> seq)
Sequence the given seq and collect the output as a set; use the given ord to order the set.
|
static <B> Stream<Seq<B>> |
sequenceStream(Seq<Stream<B>> seq)
Sequence the given seq and collect the output as a stream.
|
static <B> Trampoline<Seq<B>> |
sequenceTrampoline(Seq<Trampoline<B>> seq)
Sequence the given seq and collect the output as a trampoline.
|
static <E,B> Validation<E,Seq<B>> |
sequenceValidation(Semigroup<E> semigroup,
Seq<Validation<E,B>> seq)
Sequence the given seq and collect the output as a validation; use the given semigroup to reduce the errors.
|
static <E,B> Validation<E,Seq<B>> |
sequenceValidation(Seq<Validation<E,B>> seq)
Sequence the given seq and collect the output as a validation.
|
static <A> Seq<A> |
single(A a)
A singleton sequence.
|
Seq<A> |
snoc(A a)
Inserts the given element at the end of this sequence.
|
P2<Seq<A>,Seq<A>> |
split(int i)
Splits this sequence into a pair of sequences at the given position.
|
Seq<A> |
tail()
The sequence without the first element.
|
Seq<A> |
take(int n)
Takes the given number of elements from the head of this sequence if they are available.
|
java.util.List<A> |
toJavaList()
Converts the sequence to a java.util.List
|
List<A> |
toList()
Converts this sequence to a List
|
Stream<A> |
toStream()
Converts this sequence to a Stream
|
java.lang.String |
toString() |
<B,L> Either<L,Seq<B>> |
traverseEither(F<A,Either<L,B>> f)
Traverse this seq with the given function and collect the output on the right side of an either.
|
<R,B> Either<Seq<B>,R> |
traverseEitherLeft(F<A,Either<B,R>> f)
Traverse this seq with the given function and collect the output on the left side of an either.
|
<L,B> Either<L,Seq<B>> |
traverseEitherRight(F<A,Either<L,B>> f)
Traverse this seq with the given function and collect the output on the right side of an either.
|
<C,B> F<C,Seq<B>> |
traverseF(F<A,F<C,B>> f)
Traverse this seq with the given function and collect the output as a function.
|
<B> IO<Seq<B>> |
traverseIO(F<A,IO<B>> f)
Traverse this seq with the given function and collect the output as an IO.
|
<B> List<Seq<B>> |
traverseList(F<A,List<B>> f)
Traverse this seq with the given function and collect the output as a list.
|
<B> Option<Seq<B>> |
traverseOption(F<A,Option<B>> f)
Traverses through the Seq with the given function
|
<B> P1<Seq<B>> |
traverseP1(F<A,P1<B>> f)
Traverse this seq with the given function and collect the output as a p1.
|
<B> Seq<Seq<B>> |
traverseSeq(F<A,Seq<B>> f)
Traverse this seq with the given function and collect the output as a seq.
|
<B> Set<Seq<B>> |
traverseSet(Ord<B> ord,
F<A,Set<B>> f)
Traverse this seq with the given function and collect the output as a set; use the given ord to order the set.
|
<B> Stream<Seq<B>> |
traverseStream(F<A,Stream<B>> f)
Traverse this seq with the given function and collect the output as a stream.
|
<B> Trampoline<Seq<B>> |
traverseTrampoline(F<A,Trampoline<B>> f)
Traverse this seq with the given function and collect the output as a trampoline.
|
<E,B> Validation<E,Seq<B>> |
traverseValidation(F<A,Validation<E,B>> f)
Traverse this seq with the given function and collect the output as a validation.
|
<E,B> Validation<E,Seq<B>> |
traverseValidation(Semigroup<E> semigroup,
F<A,Validation<E,B>> f)
Traverse this seq with the given function and collect the output as a validation; use the given semigroup to reduce the errors.
|
Seq<A> |
update(int i,
A a)
Replace the element at the given index with the supplied value.
|
public static <A> Seq<A> empty()
public boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic static <A> Seq<A> single(A a)
a - The single element in the sequence.@SafeVarargs public static <A> Seq<A> seq(A... as)
as - The elements to create the sequence from.public static <A> Seq<A> listSeq(List<A> list)
list - The list to create the sequence from.public static <A> Seq<A> iterableSeq(java.lang.Iterable<A> i)
i - The iterable to create the sequence from.public static <A> Seq<A> iteratorSeq(java.util.Iterator<A> i)
i - The iterator to create the sequence from.@SafeVarargs public static <A> Seq<A> arraySeq(A... as)
public static <A> Seq<A> fromJavaList(java.util.List<A> list)
list - The list to create the sequence from.public Seq<A> cons(A a)
a - An element to insert at the front of this sequence.public Seq<A> snoc(A a)
a - An element to insert at the end of this sequence.public A head()
public A last()
public Seq<A> tail()
public Seq<A> init()
public java.util.List<A> toJavaList()
public java.util.Iterator<A> iterator()
for-each loop.iterator in interface java.lang.Iterable<A>public java.lang.String toString()
toString in class java.lang.Objectpublic Seq<A> append(Seq<A> as)
as - A sequence to append to this one.public boolean isEmpty()
public Seq<A> insert(int index, A a)
index - The index of the element to return.public boolean isNotEmpty()
public int length()
public P2<Seq<A>,Seq<A>> split(int i)
i
and the subsequence containing elements with indices greater than or equal to i.public A index(int i)
i - The index of the element to return.public Seq<A> update(int i, A a)
i - The index of the element to update.a - The new value.public Seq<A> delete(int i)
i - The index of the element to update.public Seq<A> take(int n)
n - The maximum number of elements to take from this sequence.public Seq<A> drop(int n)
n - The number of elements to drop from this sequence.public int hashCode()
hashCode in class java.lang.Objectpublic <B> Seq<B> bind(F<A,Seq<B>> f)
B - the type of the seq valuef - the given functionpublic static <L,B> Either<L,Seq<B>> sequenceEither(Seq<Either<L,B>> seq)
B - the type of the right valueL - the type of the left valueseq - the given seqpublic static <R,B> Either<Seq<B>,R> sequenceEitherLeft(Seq<Either<B,R>> seq)
R - the type of the right valueB - the type of the left valueseq - the given seqpublic static <L,B> Either<L,Seq<B>> sequenceEitherRight(Seq<Either<L,B>> seq)
B - the type of the right valueL - the type of the left valueseq - the given seqpublic static <C,B> F<C,Seq<B>> sequenceF(Seq<F<C,B>> seq)
C - the type of the input valueB - the type of the output valueseq - the given seqpublic static <B> IO<Seq<B>> sequenceIO(Seq<IO<B>> seq)
B - the type of the IO valueseq - the given seqpublic static <B> List<Seq<B>> sequenceList(Seq<List<B>> seq)
B - the type of the seq valueseq - the given seqpublic static <B> Option<Seq<B>> sequenceOption(Seq<Option<B>> seq)
B - the type of the seq valueseq - the given seqpublic static <B> P1<Seq<B>> sequenceP1(Seq<P1<B>> seq)
B - the type of the P1 valueseq - the given seqpublic static <B> Seq<Seq<B>> sequenceSeq(Seq<Seq<B>> seq)
B - the type of the seq valueseq - the given seqpublic static <B> Set<Seq<B>> sequenceSet(Ord<B> ord, Seq<Set<B>> seq)
B - the type of the set valueord - the given ordseq - the given seqpublic static <B> Stream<Seq<B>> sequenceStream(Seq<Stream<B>> seq)
B - the type of the stream valueseq - the given seqpublic static <B> Trampoline<Seq<B>> sequenceTrampoline(Seq<Trampoline<B>> seq)
B - the type of the stream valueseq - the given trampolinepublic static <E,B> Validation<E,Seq<B>> sequenceValidation(Seq<Validation<E,B>> seq)
E - the type of the failure valueB - the type of the success valueseq - the given seqpublic static <E,B> Validation<E,Seq<B>> sequenceValidation(Semigroup<E> semigroup, Seq<Validation<E,B>> seq)
E - the type of the failure valueB - the type of the success valuesemigroup - the given semigroupseq - the given seqpublic <B,L> Either<L,Seq<B>> traverseEither(F<A,Either<L,B>> f)
L - the type of the left valueB - the type of the right valuef - the given functionpublic <R,B> Either<Seq<B>,R> traverseEitherLeft(F<A,Either<B,R>> f)
R - the type of the left valueB - the type of the right valuef - the given functionpublic <L,B> Either<L,Seq<B>> traverseEitherRight(F<A,Either<L,B>> f)
L - the type of the left valueB - the type of the right valuef - the given functionpublic <C,B> F<C,Seq<B>> traverseF(F<A,F<C,B>> f)
C - the type of the input valueB - the type of the output valuef - the given functionpublic <B> IO<Seq<B>> traverseIO(F<A,IO<B>> f)
B - the type of the IO valuef - the given functionpublic <B> List<Seq<B>> traverseList(F<A,List<B>> f)
B - the type of the list valuef - the given functionpublic <B> Option<Seq<B>> traverseOption(F<A,Option<B>> f)
f - The function that produces Option valuepublic <B> P1<Seq<B>> traverseP1(F<A,P1<B>> f)
B - the type of the p1 valuef - the given functionpublic <B> Seq<Seq<B>> traverseSeq(F<A,Seq<B>> f)
B - the type of the seq valuef - the given functionpublic <B> Set<Seq<B>> traverseSet(Ord<B> ord, F<A,Set<B>> f)
B - the type of the set valueord - the given ordf - the given functionpublic <B> Stream<Seq<B>> traverseStream(F<A,Stream<B>> f)
B - the type of the stream valuef - the given functionpublic <B> Trampoline<Seq<B>> traverseTrampoline(F<A,Trampoline<B>> f)
B - the type of the trampoline valuef - the given functionpublic <E,B> Validation<E,Seq<B>> traverseValidation(F<A,Validation<E,B>> f)
E - the type of the failure valueB - the type of the success valuef - the given functionpublic <E,B> Validation<E,Seq<B>> traverseValidation(Semigroup<E> semigroup, F<A,Validation<E,B>> f)
E - the type of the failure valueB - the type of the success valuesemigroup - the given semigroupf - the given function