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.
|
Seq<A> |
cons(A a)
Inserts the given element at the front of this sequence.
|
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) |
<B> B |
foldLeft(F2<B,A,B> f,
B z) |
<B> B |
foldRight(F2<A,B,B> f,
B z) |
int |
hashCode() |
A |
head()
The first element of this sequence.
|
A |
index(int i)
Returns the element at the given index.
|
Seq<A> |
init()
The sequence without the last element.
|
boolean |
isEmpty()
Checks if this is the empty sequence.
|
boolean |
isNotEmpty()
Checks if this sequence is not empty.
|
java.util.Iterator<A> |
iterator()
Returns an iterator for this seq.
|
A |
last()
The last element of this sequence.
|
int |
length()
Returns the number of elements in this sequence.
|
<B> Seq<B> |
map(F<A,B> f) |
static <A> Seq<A> |
seq(A... as) |
static <A> Seq<A> |
seq(List<A> list) |
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) |
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() |
Stream<A> |
toStream() |
java.lang.String |
toString() |
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.Object
public static <A> Seq<A> single(A a)
a
- The single element in the sequence.public static <A> Seq<A> seq(A... as)
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 final java.util.List<A> toJavaList()
public final 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.Object
public Seq<A> append(Seq<A> as)
as
- A sequence to append to this one.public boolean isEmpty()
public boolean isNotEmpty()
public int length()
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> 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.Object