T
- the type of the sequence elementspublic interface Sq<T>
Modifier and Type | Method and Description |
---|---|
Sq<T> |
concat(Sq<T> that)
Return a sequence consisting of all the elements of this sequence,
followed by all the elements of the given sequence
that . |
static <T> Sq<T> |
constant(T v)
Return an infinite sequence consisting of a single element repeated
infintely.
|
Sq<T> |
dropWhile(Predicate<T> p)
Return a sequence consisting of the elements of this sequence except all
the leading ones satisfying predicate
p . |
static <T> Sq<T> |
empty()
Return an empty sequence.
|
default T |
findFirst(Predicate<T> p)
Return the first element of this sequence satisfying predicate
p . |
T |
head()
Return the head (first element) of this sequence.
|
boolean |
isEmpty()
Return true if this sequence contains no elements.
|
static <T> Sq<T> |
iterate(T start,
UnaryOperator<T> next)
Returns an infinite sequence produced by iterative application of a
function
next to an initial element start ,
producing a sequence consisting of start ,
next(start) , next(next(start)) , etc. |
Sq<T> |
limit(int n)
Return a sequence consisting of the elements of this sequence, truncated
to be no longer than
n in length. |
static <T> Sq<T> |
repeat(int n,
T v)
Return a finite sequence consisting of
n copies of the given
element v . |
Sq<T> |
tail()
Return the tail of this sequence.
|
Sq<T> |
takeWhile(Predicate<T> p)
Return a sequence consisting of the longest prefix of this sequence
composed of elements satisfying the predicate
p . |
static <T> Sq<T> empty()
T
- the type of the sequence's elementsstatic <T> Sq<T> constant(T v)
T
- the type of the sequence's elementsv
- the element to be repeated in the sequencestatic <T> Sq<T> repeat(int n, T v)
n
copies of the given
element v
.T
- the type of the sequence's elementsn
- the length of the resulting sequencev
- the element to be repeated in the sequenceIllegalArgumentException
- if n is negativestatic <T> Sq<T> iterate(T start, UnaryOperator<T> next)
next
to an initial element start
,
producing a sequence consisting of start
,
next(start)
, next(next(start))
, etc. The first
element in the sequence will be the provided start
. For n
> 0, the element at position n, will be the result of applying the
function next
to the element at position n - 1.T
- the type of the sequence's elementsstart
- the initial elementnext
- a function to be applied to the previous element to produce
the next elementboolean isEmpty()
T head()
NoSuchElementException
- if this sequence is emptySq<T> tail()
NoSuchElementException
- if this sequence is emptySq<T> limit(int n)
n
in length.n
- the number of elements the sequence should be limited toIllegalArgumentException
- if n is negativeSq<T> concat(Sq<T> that)
that
.that
- the sequence to concatenate at the end of this oneSq<T> takeWhile(Predicate<T> p)
p
.p
- the predicateSq<T> dropWhile(Predicate<T> p)
p
.p
- the predicate used to filter the prefixdefault T findFirst(Predicate<T> p)
p
.p
- the predicate that the returned element must satisfyNoSuchElementException
- if no element of this sequence satisfies the predicate