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.
|
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) |
<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.
|
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)
Deprecated.
As of release 4.5, use
iterableSeq(java.lang.Iterable<A>) |
<B> Seq<B> |
map(F<A,B> f) |
static <A> Seq<A> |
seq(A... as)
Constructs a sequence from the given elements.
|
static <A> Seq<A> |
seq(List<A> list)
Deprecated.
As of release 4.5, use
listSeq(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)
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() |
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.@SafeVarargs public static <A> Seq<A> seq(A... as)
as
- The elements to create the sequence from.@Deprecated public static <A> Seq<A> seq(List<A> list)
listSeq(List)
list
- The list to create the sequence from.@Deprecated public static <A> Seq<A> listSeq(List<A> list)
iterableSeq(java.lang.Iterable<A>)
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.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 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.Object