Returns true
if all elements match the given predicate
.
Returns true
if at least one element match the given predicate
.
Returns an iterable representation of the sequence.
Transforms each element into a key-value pair and returns the results as map. In case of duplicate keys the last key-value pair overrides the other.
Returns a map consisting of the elements mapped by the given keySelector
.
Returns a map consisting of the elements indexed by the given key
.
Returns a map consisting of the elements mapped by the given keySelector
. The value
is transformed into another value by the valueTransformer
.
Returns a map consisting of the elements indexed by the given key
. The value
is transformed into another value by the valueTransformer
.
Returns the average of all numbers of the sequence or NaN
if the sequence is empty.
Splits the elements of the sequence into arrays which length is determined by
the given chunkSize
and returns all chunks as array.
Returns true
if the sequence contains the given element
.
Returns the number of elements of this sequence. If predicate
is present, returns
the number of elements matching the given predicate
.
Returns the element at position index
(zero-based) or throws an error if index
is out of bounds.
Returns the element at position index
(zero-based). If index
is out of bounds returns
the result of the given defaultValue
function.
Returns the element at position index
(zero-based) or null
if index
is out of bounds.
Returns the first element of the sequence or the first element matching predicate
if present, otherwise returns null
.
Returns the last element of the sequence or the last element matching predicate
if present, otherwise returns null
.
Returns the first element of the sequence or the first element matching predicate
if present, otherwise throws
an error.
Returns the first element of the sequence or the first element matching predicate
if present, otherwise returns null
.
Accumulates all elements of the sequence into a single result by applying the given operation
starting with
the initial
value. The result of the last operation will be passed as accumulated value to the getNext invocation
of the operation until all elements of the sequence are processed.
Accumulates all elements of the sequence into a single result by applying the given operation
starting with
the initial
value. The result of the last operation will be passed as accumulated value to the getNext invocation
of the operation as well as the index
of the current element (zero-based) until all elements of the sequence
are processed.
Performs the given action
(side-effect) for each element of the sequence.
Performs the given action
(side-effect) for each element of the sequence and passes the index
of the current
element (zero-based).
Groups all elements of the sequence into a map. Keys are determined by the given keySelector
function.
Returns the zero-based index of the given element
or -1 if the sequence does not contain the element.
Returns the zero-based index of the first element matching the given predicate
or -1 if no element matches
the predicate.
Returns the zero-based index of the last element matching the given predicate
or -1 if no element matches
the predicate.
Joins all elements of the sequence into a string with the given configuration.
Joins all elements of the sequence into a string with the given configuration.
Returns the last element of the sequence or the last element matching predicate
if present, otherwise throws
an error.
Returns the last element of the sequence or the last element matching predicate
if present, otherwise returns null
.
Returns the maximum element of the sequence or null
if sequence is empty.
Returns the maximum element by comparing the results of the given selector
function
for each element of the sequence or null
if the sequence is empty.
Returns the maximum element of the sequence by evaluating the given compare
function or null
if sequence is empty.
Merges the elements of both sequences into a new sequence. Each element of this sequence is eventually replaced with
an element of the other sequence by comparing results of the given selector
function. If no value is found in the other
sequence the element is retained. New elements of the other sequence are appended to the end of the new sequence or
prepended to the start of the new sequence, if prependNewValues
is set to true
. This operation is not lazy evaluated.
Returns the minimum element of the sequence or null
if sequence is empty.
Returns the minimum element by comparing the results of the given selector
function
for each element of the sequence or null
if the sequence is empty.
Returns the minimum element of the sequence by evaluating the given compare
function or null
if sequence is empty.
Returns true
if no element match the given predicate
or if the sequence is empty
if no predicate is present.
Evaluates the given predicate
for each element of the sequence and assorts each element into one of two lists
according to the result of the predicate. Returns both lists as an object.
Appends the given element
to the end of the sequence and returns a new sequence.
Appends the given array to the end of the sequence and returns a new sequence.
Appends the given sequence to the end of the sequence and returns a new sequence.
Reduces the whole sequence to a single value by invoking operation
with each element
from left to right. For every invocation of the operation acc
is the result of the last
invocation. For the first invocation of the operation acc
is the first element of the
sequence.
Reduces the whole sequence to a single value by invoking operation
with each element
from left to right. For every invocation of the operation acc
is the result of the last
invocation. For the first invocation of the operation acc
is the first element of the
sequence. In addition the index
of the current element is also passed to the operation.
Returns the single element of the sequence or throws error if the sequence has more than
one element or none at all. If a predicate
is passed returns the single element matching
the predicate or throws an error if more or less than one element match the predicate.
Returns the single element of the sequence or null
if the sequence has more than
one element or none at all. If a predicate
is passed returns the single element matching
the predicate or null
if more or less than one element match the predicate.
Returns a new sequence with all elements sorted by the comparator specified by the given composeComparator
function
or in natural order if no arguments are given.
Returns the sum of all numbers.
Returns the sum of all numbers specified by the given selector
function.
Returns all elements of the sequence as array. If an array
is passed
the elements are appended to the end of the array.
Returns all elements of the sequence as array. If an array
is passed
the elements are appended to the end of the array.
Returns a map consisting of each key-value pair. If a map
is passed
the pairs are set on this map. Duplicate keys override each other.
Returns all elements of the sequence as set. If a set
is passed
the elements are added to this set.
Returns a pair of arrays where the first array contains all first values and the second array all second values from each input pair of the sequence.
A Sequence provides a fluent functional API consisting of various intermediate and terminal operations for processing the iterated data. The operations are evaluated lazily to avoid examining all the input data when it's not necessary. Sequences can be iterated only once.