Attributes
emptySource Codeshared actual Boolean empty

Determines if the stream is empty, that is to say, if the iterator returns no elements.

Refines Collection.empty ultimately refines Iterable.empty
sizeSource Codeshared actual Integer size

The number of elements returned by the Iterable.iterator() of this stream, if the iterator terminates. In the case of an infinite stream, this operation never terminates.

Inherited Attributes
Attributes inherited from: Object
Attributes inherited from: Collection<Element>
Attributes inherited from: Iterable<Element,Absent>
Attributes inherited from: Set<Element>
Methods
anySource 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 false. For an infinite stream, this operation might not terminate.

Refines Iterable.any
bySource Codeshared actual {Nothing*} by(Integer step)

Produces a stream containing every stepth element of this stream. If the step size is 1, the resulting stream contains the same elements as this stream.

For example, the expression

(0..10).by(3)

results in the stream { 0, 3, 6, 9 }.

The step size must be greater than zero.

Refines Iterable.by
cloneSource Codeshared actual Set<Nothing> clone()

A shallow copy of this collection, that is, a collection with identical elements which does not change if this collection changes. If this collection is immutable, it is acceptable to return a reference to this collection. If this collection is mutable, a newly instantiated collection must be returned.

Refines Set.clone ultimately refines Collection.clone
complementSource Codeshared actual Set<Nothing> complement<Other>(Set<Other> set)
given Other satisfies Object

Returns a new Set containing all the elements in this set that are not contained in the given Set.

For example:

set { "hello", "world" } ~ set { 1, 2, "hello" }

Produces the set { "world" } of type Set<String>.

containsSource Codeshared actual Boolean contains(Object element)

Returns true if the given value belongs to this Category, that is, if it is an element of this Category, or false otherwise.

For most Categorys the following relationship is satisfied by every pair of elements x and y:

  • if x==y, then x in category == y in category

However, it is possible to form a useful Category consistent with some other equivalence relation, for example ===. Therefore implementations of contains() which do not satisfy this relationship are tolerated.

Refines Set.contains ultimately refines Category.contains
containsAnySource Codeshared actual Boolean containsAny({Object*} elements)

Returns true if any one of the given values belongs to this Category, or false otherwise.

containsEverySource Codeshared actual Boolean containsEvery({Object*} elements)

Returns true if every one of the given values belongs to this Category, or false otherwise.

countSource Codeshared actual Integer count(Boolean selecting(Nothing element))

Produces the number of elements in this stream that satisfy the given predicate function. For an infinite stream, this method never terminates.

eachSource 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 loop:

for (word in words) {
    print(word.lowercased);
    print(word.uppercased);
}

For certain streams this method is highly efficient, surpassing the performance of for loops on the JVM. Thus, each() is sometimes preferred in highly performance-critical low-level code.

everySource 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 true. For an infinite stream, this operation might not terminate.

exclusiveUnionSource Codeshared actual Set<Other> exclusiveUnion<Other>(Set<Other> set)
given Other satisfies Object

Returns a new Set containing only the elements contained in either this set or the given Set, but no element contained in both sets.

findSource Codeshared actual Null find(Boolean selecting(Nothing element))

The first element of this stream which satisfies the given predicate function, if any, or null if there is no such element. For an infinite stream, this method might not terminate.

For example, the expression

(-10..10).find(Integer.positive)

evaluates to 1.

findLastSource Codeshared actual Null findLast(Boolean selecting(Nothing element))

The last element of this stream which satisfies the given predicate function, if any, or null if there is no such element. For an infinite stream, this method will not terminate.

For example, the expression

(-10..10).findLast(3.divides)

evaluates to 9.

intersectionSource Codeshared actual Set<Nothing> intersection<Other>(Set<Other> set)
given Other satisfies Object

Returns a new Set containing only the elements that are present in both this set and the given Set and that are instances of the intersection Element&Other of the element types of the two sets.

For example:

set { "hello", "world" } & set { 1, 2, "hello" }

Produces the set { "hello" } of type Set<String>.

Note that, according to this definition, and even though 1==1.0 evaluates to true, the expression

set { 1 } & set { 1.0 }

produces the empty set {}.

iteratorSource Codeshared actual Iterator<Nothing> iterator()

An iterator for the elements belonging to this stream.

skipSource Codeshared actual {Nothing*} skip(Integer skipping)

Produces a stream containing the elements of this stream, after skipping the first skipping elements produced by its iterator.

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.

subsetSource Codeshared actual Boolean subset(Set<Object> set)

Determines if this set is a subset of the given Set, that is, if the given set contains all of the elements in this set.

Refines Set.subset
supersetSource Codeshared actual Boolean superset(Set<Object> set)

Determines if this set is a superset of the given Set, that is, if this set contains all of the elements in the given set.

Refines Set.superset
takeSource Codeshared actual {Nothing*} take(Integer taking)

Produces a stream containing the first taking elements of this stream.

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.

unionSource Codeshared actual Set<Other> union<Other>(Set<Other> set)
given Other satisfies Object

Returns a new Set containing all the elements of this set and all the elements of the given Set.

For example:

set { "hello", "world" } | set { 1, 2, "hello" }

Produces the set { "hello", "world", 1, 2 } of type Set<String|Integer>.

Note that it is possible for two sets of disjoint element type to be considered to have elements in common. For example, since 1==1.0 evaluates to true, the expression

set { 1 } | set { 1.0 }

produces the set { 1 }.

Refines Set.union
Inherited Methods
Methods inherited from: Object
Methods inherited from: Category<Element>
Methods inherited from: Collection<Element>
Methods inherited from: Iterable<Element,Absent>
Methods inherited from: Set<Element>