Initializer |
Singleton(Element element) |
Attributes | |
coalesced | Source Codeshared actual Singleton<Element&Object>|[] coalesced The non-null elements of this stream, in the order in which they occur in this stream. For null elements of the original stream, there is no entry in the resulting stream. For example, the expression { "123", "abc", "456"}.map(parseInteger).coalesced results in the stream Refines Iterable.coalesced |
cycled | Source Codeshared actual {Element+} cycled An infinite stream that produces the For example, the expression Singleton(null).cycled.take(4) evaluates to the stream See also Sequence.repeat() Refines Iterable.cycled |
distinct | Source Codeshared actual Singleton<Element> distinct This singleton. Refines Iterable.distinct |
first | Source Codeshared actual Element first Returns the element contained in this |
hash | Source Codeshared actual Integer hash The hash value of the value, which allows the value to be an element of a hash-based set or key of a hash-based map. Implementations must respect the constraint that:
Therefore, a class which refines In general, Note that when executing on a Java Virtual Machine, the
64-bit |
indexed | Source Codeshared actual {<Integer->Element>+} indexed A stream containing all entries of form
For example, the expression { "hello", null, "world" }.indexed results in the stream Refines Iterable.indexed |
last | Source Codeshared actual Element last Returns the element contained in this |
lastIndex | Source Codeshared actual Integer lastIndex Returns |
paired | Source Codeshared actual [] paired An empty stream. Refines Iterable.paired |
rest | Source Codeshared actual [] rest Returns |
reversed | Source Codeshared actual Singleton<Element> reversed Return this singleton. |
size | Source Codeshared actual Integer size Returns |
string | Source Codeshared actual String string A developer-friendly string representing the instance.
Concatenates the name of the concrete class of the
instance with the |
Inherited Attributes |
Attributes inherited from: Object |
Attributes inherited from: Collection<Element> |
Attributes inherited from: Correspondence<Key,Item> |
Attributes inherited from: Iterable<Element,Absent> |
Attributes inherited from: List<Element> |
Attributes inherited from: [Element+] |
Attributes inherited from: Element[] |
Methods | |
any | Source Codeshared actual Boolean any(Boolean selecting(Element e)) Determines if there is at least one element of this
stream that satisfies the given predicate
function. If the stream is empty, returns
Refines Iterable.any |
chain | Source Codeshared actual {Element|Other+} chain<Other, OtherAbsent>(Iterable<Other,OtherAbsent> other) The elements of this stream, in the order in which they occur in this stream, followed by the elements of the given stream in the order in which they occur in the given stream. For example, the expression (1..3).chain("abc") evaluates to the stream Refines Iterable.chain |
clone | Source Codeshared actual Singleton<Element> clone() Returns a |
collect | Source Codeshared actual Singleton<Result> collect<Result>(Result collecting(Element element)) Produce a new sequence containing the results of applying the given mapping to the elements of this stream. This operation is an eager counterpart to it.collect(f) == [*it.map(f)] |
contains | Source Codeshared actual Boolean contains(Object element) Returns |
count | Source Codeshared actual Integer count(Boolean selecting(Element element)) Returns Refines Iterable.count |
each | Source Codeshared actual void each(void step(Element element)) Call the given function for each element of this stream, passing the elements in the order they occur in this stream. For example: words.each((word) { print(word.lowercased); print(word.uppercased); }); Has the same effect as the following for (word in words) { print(word.lowercased); print(word.uppercased); } For certain streams this method is highly efficient,
surpassing the performance of Refines Iterable.each |
equals | Source Codeshared actual Boolean equals(Object that) A |
every | Source Codeshared actual Boolean every(Boolean selecting(Element e)) Determines if all elements of this stream satisfy the
given predicate function. If the stream
is empty, return Refines Iterable.every |
filter | Source Codeshared actual Singleton<Element>|[] filter(Boolean selecting(Element e)) Produces a stream containing the elements of this stream that satisfy the given predicate function. For any empty stream, {}.filter(p) == {} For any nonempty stream it.filter(p) == { if (p(it.first)) it.first }.chain(it.rest.filter(f)) Alternatively, and in practice, it.filter(p) == { for (e in it) if (p(e)) e }; For example, the expression (1..100).filter(13.divides) results in the stream Refines Iterable.filter |
find | Source Codeshared actual Element? find(Boolean selecting(Element&Object e)) The first element of this stream which is not null and
satisfies the given predicate function,
if any, or For example, the expression (-10..10).find(Integer.positive) evaluates to |
findLast | Source Codeshared actual Element? findLast(Boolean selecting(Element&Object e)) The last element of this stream which is not null and
satisfies the given predicate function,
if any, or For example, the expression (-10..10).findLast(3.divides) evaluates to |
fold | Source Codeshared actual Result fold<Result>(Result initial)(Result accumulating(Result partial, Element e)) Beginning with a given initial value, apply the given combining function to each element of this stream in turn, progressively accumulating a single result. For an empty stream, {}.fold(z)(f) == z For a given nonempty stream it.fold(z)(f) == f(it.exceptLast.fold(z)(f), it.last) For example, the expression (1..100).fold(0)(plus) results in the integer Refines Iterable.fold |
follow | Source Codeshared actual {Other|Element+} follow<Other>(Other head) A stream with given For example, the expression Singleton(1).follow(2) evaluates to the stream Refines Iterable.follow |
getFromFirst | Source Codeshared actual Element? getFromFirst(Integer index) Returns the contained element, if the specified
index is |
initial | Source Codeshared actual []|Singleton<Element> initial(Integer length) Select the first elements of this list, returning a
list no longer than the given length. If this list is
shorter than the given length, return this list.
Otherwise return a list of the given length. If
For any list.initial(length) == list[...length-1] == list[0:length] This is an eager operation. |
interpose | Source Codeshared actual Singleton<Element> interpose<Other>(Other element, Integer step) |
iterator | Source Codeshared actual Iterator<Element> iterator() An iterator for the elements belonging to this stream. If this is a nonempty stream with type |
map | Source Codeshared actual Singleton<Result> map<Result>(Result collecting(Element e)) Produces a stream containing the results of applying the given mapping to the elements of this stream. For any empty stream, {}.map(f) == {} For any nonempty stream it.map(f).first == f(it.first) it.map(f).rest == it.rest.map(f) Alternatively, and in practice, it.map(f) == { for (e in it) f(e) } For example, the expression (0..4).map(10.power) results in the stream Refines Iterable.map |
measure | Source Codeshared actual []|Singleton<Element> measure(Integer from, Integer length) Returns a |
reduce | Source Codeshared actual Element reduce<Result>(Result accumulating(Result|Element partial, Element e)) Beginning with the For an empty stream, For a stream with one element, { first }.reduce(f) == first For a given stream it.reduce(f) == f(it.exceptLast.reduce(f), it.last) For example, the expression (1..100).reduce(plus) results in the integer Refines Iterable.reduce |
select | Source Codeshared actual Singleton<Element>|[] select(Boolean selecting(Element element)) Produce a new sequence containing all elements of this stream that satisfy the given predicate function, in the order in which they occur in this stream. This operation is an eager counterpart to it.select(p) == [*it.filter(p)] Refines Iterable.select |
skip | Source Codeshared actual Singleton<Element>|[] skip(Integer skipping) Produces a stream containing the elements of this
stream, after skipping the first If this stream does not contain more elements than the specified number of elements to skip, the resulting stream has no elements. If the specified number of elements to skip is zero or fewer, the resulting stream contains the same elements as this stream. Refines Iterable.skip |
slice | Source Codeshared actual [[], Singleton<Element>]|[Singleton<Element>, []] slice(Integer index) Return two lists, the first containing the elements
that occur before the given For any list.slice(index) == [list[...index-1], list[index...]] This is an eager operation. |
sort | Source Codeshared actual Singleton<Element> sort(Comparison comparing(Element a, Element b)) Produce a new sequence containing the elements of this stream, sorted according to the given comparator function imposing a partial order upon the elements of the stream. For convenience, the functions For example, this expression "Hello World!".sort(byIncreasing(Character.lowercased)) evaluates to the sequence
This operation is eager by nature. Note that the toplevel function |
span | Source Codeshared actual []|Singleton<Element> span(Integer from, Integer to) Returns a |
spanFrom | Source Codeshared actual []|Singleton<Element> spanFrom(Integer from) Obtain a span containing the elements between the given starting index and the last index of this ranged object. For any ranged stream r[from...] The span should contain elements of this stream,
starting from the element at the given starting
index, in the same order as they are produced by
the When the given index does not belong to this ranged stream, the behavior is implementation dependent. |
spanTo | Source Codeshared actual []|Singleton<Element> spanTo(Integer to) Obtain a span containing the elements between the first index of this ranged stream and given end index. For any ranged stream r[...to] The span should contain elements of this stream, up to
the element at the given ending index, in the
same order as they are produced by the When the given index does not belong to this ranged stream, the behavior is implementation dependent. |
take | Source Codeshared actual Singleton<Element>|[] take(Integer taking) Produces a stream containing the first If the specified number of elements to take is larger than the number of elements of this stream, the resulting stream contains the same elements as this stream. If the specified number of elements to take is fewer than one, the resulting stream has no elements. Refines Iterable.take |
terminal | Source Codeshared actual []|Singleton<Element> terminal(Integer length) Select the last elements of the list, returning a list no longer than the given length. If this list is shorter than the given length, return this list. Otherwise return a list of the given length. For any list.terminal(length) == list[size-length...] This is an eager operation. |