Class Seq<A>
java.lang.Object
fj.data.Seq<A>
- All Implemented Interfaces:
Iterable<A>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAppends the given sequence to this sequence.static <A> Seq<A> arraySeq(A... as) Constructs a sequence from the array.<B> Seq<B> Bind the given function across this seq.private voidcheckBounds(int i) Inserts the given element at the front of this sequence.delete(int i) Delete the element at the given index.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<B> B<B> Bstatic <A> Seq<A> fromJavaList(List<A> list) Constructs a sequence from the given list.inthashCode()head()The first element of this sequence.index(int i) Returns the element at the given index.init()The sequence without the last element.Inserts the element at the given index.booleanisEmpty()Checks if this is the empty sequence.booleanChecks if this sequence is not empty.static <A> Seq<A> iterableSeq(Iterable<A> i) Constructs a sequence from the iterable.iterator()Returns an iterator for this seq.static <A> Seq<A> iteratorSeq(Iterator<A> i) Constructs a sequence from the iterator.last()The last element of this sequence.intlength()Returns the number of elements in this sequence.static <A> Seq<A> Constructs a sequence from the given list.<B> Seq<B> mkTree()static <A> Seq<A> seq(A... as) Constructs a sequence from the given elements.sequenceEither(Seq<Either<L, B>> seq) Sequence the given seq and collect the output on the right side of an either.sequenceEitherLeft(Seq<Either<B, R>> seq) Sequence the given seq and collect the output on the left side of an either.sequenceEitherRight(Seq<Either<L, B>> seq) Sequence the given seq and collect the output on the right side of an either.Sequence the given seq and collect the output as a function.sequenceIO(Seq<IO<B>> seq) Sequence the given seq and collect the output as an IO.sequenceList(Seq<List<B>> seq) Sequence the given seq and collect the output as a list.sequenceOption(Seq<Option<B>> seq) Sequence the given seq and collect the output as an seq.sequenceP1(Seq<P1<B>> seq) Sequence the given seq and collect the output as a P1.sequenceSeq(Seq<Seq<B>> seq) Sequence the given seq and collect the output as a seq.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.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(Seq<Validation<E, B>> seq) Sequence the given seq and collect the output as a validation.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 <A> Seq<A> single(A a) A singleton sequence.Inserts the given element at the end of this sequence.split(int i) Splits this sequence into a pair of sequences at the given position.tail()The sequence without the first element.take(int n) Takes the given number of elements from the head of this sequence if they are available.Converts the sequence to a java.util.ListtoList()Converts this sequence to a ListtoStream()Converts this sequence to a StreamtoString()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.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.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.Traverse this seq with the given function and collect the output as a function.traverseIO(F<A, IO<B>> f) Traverse this seq with the given function and collect the output as an IO.traverseList(F<A, List<B>> f) Traverse this seq with the given function and collect the output as a list.traverseOption(F<A, Option<B>> f) Traverses through the Seq with the given functiontraverseP1(F<A, P1<B>> f) Traverse this seq with the given function and collect the output as a p1.traverseSeq(F<A, Seq<B>> f) Traverse this seq with the given function and collect the output as a seq.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.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.Replace the element at the given index with the supplied value.Methods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
ELEM_MEASURED
-
MK_TREE
-
EMPTY
-
ftree
-
-
Constructor Details
-
Seq
-
-
Method Details
-
mkTree
-
elemMeasured
-
empty
-
equals
-
single
A singleton sequence.- Parameters:
a- The single element in the sequence.- Returns:
- A new sequence with the given element in it.
-
seq
Constructs a sequence from the given elements.- Parameters:
as- The elements to create the sequence from.- Returns:
- A sequence with the given elements.
-
listSeq
-
iterableSeq
-
iteratorSeq
-
arraySeq
Constructs a sequence from the array. -
fromJavaList
-
cons
-
snoc
-
head
The first element of this sequence. This is an O(1) operation.- Returns:
- The first element if this sequence is nonempty, otherwise throws an error.
-
headOption
-
last
The last element of this sequence. This is an O(1) operation.- Returns:
- The last element if this sequence is nonempty, otherwise throws an error.
-
tail
-
init
-
toStream
-
toList
-
toJavaList
-
iterator
-
toString
-
append
-
isEmpty
public boolean isEmpty()Checks if this is the empty sequence.- Returns:
- True if this sequence is empty, otherwise false.
-
insert
-
isNotEmpty
public boolean isNotEmpty()Checks if this sequence is not empty.- Returns:
- True if this sequence is not empty, otherwise false.
-
length
public int length()Returns the number of elements in this sequence.- Returns:
- the number of elements in this sequence.
-
split
-
index
Returns the element at the given index. This is an O(log(n)) operation.- Parameters:
i- The index of the element to return.- Returns:
- The element at the given index, or throws an error if the index is out of bounds.
-
update
-
delete
-
take
Takes the given number of elements from the head of this sequence if they are available.- Parameters:
n- The maximum number of elements to take from this sequence.- Returns:
- A sequence consisting only of the first n elements of this sequence, or else the whole sequence, if it has less than n elements.
-
drop
Drops the given number of elements from the head of this sequence if they are available.- Parameters:
n- The number of elements to drop from this sequence.- Returns:
- A sequence consisting of all elements of this sequence except the first n ones, or else the empty sequence, if this sequence has less than n elements.
-
checkBounds
private void checkBounds(int i) -
foldLeft
-
foldRight
-
filter
-
hashCode
-
map
-
bind
-
sequenceEither
-
sequenceEitherLeft
-
sequenceEitherRight
-
sequenceF
-
sequenceIO
-
sequenceList
-
sequenceOption
-
sequenceP1
-
sequenceSeq
-
sequenceSet
-
sequenceStream
-
sequenceTrampoline
Sequence the given seq and collect the output as a trampoline.- Type Parameters:
B- the type of the stream value- Parameters:
seq- the given trampoline- Returns:
- the stream
-
sequenceValidation
Sequence the given seq and collect the output as a validation.- Type Parameters:
E- the type of the failure valueB- the type of the success value- Parameters:
seq- the given seq- Returns:
- the validation
-
sequenceValidation
public 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.- Type Parameters:
E- the type of the failure valueB- the type of the success value- Parameters:
semigroup- the given semigroupseq- the given seq- Returns:
- the validation
-
traverseEither
-
traverseEitherLeft
Traverse this seq with the given function and collect the output on the left side of an either.- Type Parameters:
R- the type of the left valueB- the type of the right value- Parameters:
f- the given function- Returns:
- the either
-
traverseEitherRight
Traverse this seq with the given function and collect the output on the right side of an either.- Type Parameters:
L- the type of the left valueB- the type of the right value- Parameters:
f- the given function- Returns:
- the either
-
traverseF
-
traverseIO
-
traverseList
-
traverseOption
-
traverseP1
-
traverseSeq
-
traverseSet
-
traverseStream
-
traverseTrampoline
Traverse this seq with the given function and collect the output as a trampoline.- Type Parameters:
B- the type of the trampoline value- Parameters:
f- the given function- Returns:
- the trampoline
-
traverseValidation
Traverse this seq with the given function and collect the output as a validation.- Type Parameters:
E- the type of the failure valueB- the type of the success value- Parameters:
f- the given function- Returns:
- the validation
-
traverseValidation
public <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.- Type Parameters:
E- the type of the failure valueB- the type of the success value- Parameters:
semigroup- the given semigroupf- the given function- Returns:
- the validation
-