A sequence with no elements. The type Empty
may be
abbreviated []
, and an instance is produced by the
expression []
. That is, in the following expression,
none
has type []
and refers to the value []
:
[] none = [];
(Whether the syntax []
refers to the type or the value
depends upon how it occurs grammatically.)
Sequence
no type hierarchy
Attributes | |
coalesced | Source Codeshared actual [] coalesced Returns Refines Iterable.coalesced |
cycled | Source Codeshared actual [] cycled Returns Refines Iterable.cycled |
empty | Source Codeshared actual Boolean empty Returns |
first | Source Codeshared actual Null first Returns |
indexed | Source Codeshared actual [] indexed Returns Refines Iterable.indexed |
keys | Source Codeshared actual [] keys Returns |
last | Source Codeshared actual Null last Returns |
lastIndex | Source Codeshared actual Null lastIndex Returns Refines List.lastIndex |
paired | Source Codeshared actual [] paired Returns Refines Iterable.paired |
rest | Source Codeshared actual [] rest Returns |
reversed | Source Codeshared actual [] reversed Returns |
size | Source Codeshared actual Integer size Returns 0. |
string | Source Codeshared actual String string Returns a string description of the empty sequence:
|
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[] |
Methods | |
any | Source Codeshared actual Boolean any(Boolean selecting(Nothing element)) 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 |
append | Source Codeshared actual Other[] append<Other>(Other[] elements) Return a sequence containing the elements of this
sequence, in the order in which they occur in this
sequence, followed by the given Refines Sequential.append |
by | Source Codeshared actual [] by(Integer step) Produces a stream containing every For example, the expression (0..10).by(3) results in the stream The step size must be greater than zero. Refines Iterable.by |
chain | Source Codeshared actual Iterable<Other,OtherAbsent> chain<Other, OtherAbsent>(Iterable<Other,OtherAbsent> other) Returns the given Refines Iterable.chain |
clone | Source Codeshared actual [] clone() Returns |
collect | Source Codeshared actual [] collect<Result>(Result collecting(Nothing 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(Nothing element)) Returns 0 for any given predicate. Refines Iterable.count |
defaultNullElements | Source Codeshared actual [] defaultNullElements<Default>(Default defaultValue) Produces a stream containing the elements of this
stream, in the order in which they occur in this stream,
after replacing every For example, the expression { "123", "abc", "456" }.map(parseInteger).defaultNullElements(0) results in the stream Refines Iterable.defaultNullElements |
defines | Source Codeshared actual Boolean defines(Integer index) Returns |
each | Source Codeshared actual void each(void step(Nothing 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 |
every | Source Codeshared actual Boolean every(Boolean selecting(Nothing element)) 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 [] filter(Boolean selecting(Nothing element)) 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 Null find(Boolean selecting(Nothing element)) The first element of this stream which satisfies the
given predicate function, if any, or
For example, the expression (-10..10).find(Integer.positive) evaluates to |
firstIndexWhere | Source Codeshared actual Null firstIndexWhere(Boolean selecting(Nothing element)) The first index in this list for which the element is not null and satisfies the given predicate function. Refines List.firstIndexWhere |
flatMap | Source Codeshared actual [] flatMap<Result, OtherAbsent>(Iterable<Result,OtherAbsent> collecting(Nothing element)) Given a mapping function that accepts an
For example, the expression { "Hello", "World" }.flatMap(String.lowercased) results in this stream: { 'h', 'e', 'l', 'l', 'o', 'w', 'o', 'r,' 'l', 'd' } The expression { "hello"->"hola", "world"->"mundo" } .flatMap(Entry<String,String>.pair) produces this stream: { "hello", "hola", "world", "mundo" } Refines Iterable.flatMap |
fold | Source Codeshared actual Result fold<Result>(Result initial)(Result accumulating(Result partial, Nothing element)) 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+} follow<Other>(Other head) Produces a stream with a given initial element, followed by the elements of this stream, in the order in which they occur in this stream. For example, the expression (1..3).follow(0) evaluates to the stream Note that the expression { head, *stream } Refines Iterable.follow |
getFromFirst | Source Codeshared actual Null getFromFirst(Integer index) Returns |
getFromLast | Source Codeshared actual Null getFromLast(Integer index) Returns Refines List.getFromLast |
indexes | Source Codeshared actual [] indexes() Returns Refines Iterable.indexes |
indexesWhere | Source Codeshared actual [] indexesWhere(Boolean selecting(Nothing element)) The indexes in this list for which the element is not null and satisfies the given predicate function. Refines List.indexesWhere |
initial | Source Codeshared actual [] 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. |
iterator | Source Codeshared actual Iterator<Nothing> iterator() Returns an iterator that is already exhausted. |
lastIndexWhere | Source Codeshared actual Null lastIndexWhere(Boolean selecting(Nothing element)) The last index in this list for which the element is not null and satisfies the given predicate function. Refines List.lastIndexWhere |
map | Source Codeshared actual [] map<Result>(Result collecting(Nothing element)) 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 [] measure(Integer from, Integer length) Returns |
prepend | Source Codeshared actual Other[] prepend<Other>(Other[] elements) Return a sequence containing the given Refines Sequential.prepend |
reduce | Source Codeshared actual Null reduce<Result>(Result accumulating(Result partial, Nothing element)) 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 |
repeat | Source Codeshared actual [] repeat(Integer times) Returns |
select | Source Codeshared actual [] select(Boolean selecting(Nothing 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 |
sequence | Source Codeshared actual [] sequence() Returns |
skip | Source Codeshared actual [] 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 |
skipWhile | Source Codeshared actual [] skipWhile(Boolean skipping(Nothing elem)) Produces a stream containing the elements of this
stream, after skipping the leading elements until the
given predicate function returns Refines Iterable.skipWhile |
slice | Source Codeshared actual [][2] 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 [] sort(Comparison comparing(Nothing a, Nothing 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 Refines Iterable.sort |
span | Source Codeshared actual [] span(Integer from, Integer to) Returns |
spanFrom | Source Codeshared actual [] spanFrom(Integer from) Returns |
spanTo | Source Codeshared actual [] spanTo(Integer to) Returns |
spread | Source Codeshared actual [](*Args) spread<Result, Args>(Result(*Args) method(Nothing element)) Given a {Boolean+}(Object) fun = (-1..1).spread(Object.equals); print(fun(0)); //prints { false, true, false } Refines Iterable.spread |
sublist | Source Codeshared actual [] sublist(Integer from, Integer to) A sublist of this list, starting at the element with
index This is a lazy operation, returning a view of this list. Refines List.sublist |
sublistFrom | Source Codeshared actual [] sublistFrom(Integer from) A sublist of this list, starting at the element with the given index. This is a lazy operation, returning a view of this list. Refines List.sublistFrom |
sublistTo | Source Codeshared actual [] sublistTo(Integer to) A sublist of this list, ending at the element with the given index. This is a lazy operation, returning a view of this list. Refines List.sublistTo |
take | Source Codeshared actual [] 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 |
takeWhile | Source Codeshared actual [] takeWhile(Boolean taking(Nothing elem)) Produces a stream containing the leading elements of
this stream until the given predicate function
returns Refines Iterable.takeWhile |
terminal | Source Codeshared actual [] 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. |
trim | Source Codeshared actual [] trim(Boolean trimming(Nothing elem)) Trim the elements satisfying the given predicate function, along with any null elements, from the start and end of this list, returning a list no longer than this list. This is an eager operation. |
trimLeading | Source Codeshared actual [] trimLeading(Boolean trimming(Nothing elem)) Trim the elements satisfying the given predicate function, along with any null elements, from the start of this list, returning a list no longer than this list. This is an eager operation. |
trimTrailing | Source Codeshared actual [] trimTrailing(Boolean trimming(Nothing elem)) Trim the elements satisfying the given predicate function, along with any null elements, from the end of this list, returning a list no longer than this list. This is an eager operation. |
withLeading | Source Codeshared actual [Other] withLeading<Other>(Other element) Returns a new sequence that starts with the specified
Refines Sequential.withLeading |
withTrailing | Source Codeshared actual [Other] withTrailing<Other>(Other element) Returns a new sequence that starts with the elements of
this sequence, in the order they occur in this sequence,
and ends with the specified Refines Sequential.withTrailing |