Scoop API

scoop:scoop.std:0.1.0

src/sequences/terminal_destinations.scoop

Selected production source · src/sequences/terminal_destinations.scoop

1package scoop.sequences
3import scoop.collections.*
5/**
6 * Consumes this sequence. Adds all source elements to the destination and returns it.
7 */
8public fun <T> Sequence<T>.toCollection(destination: MutableList<T>): MutableList<T> =
9 terminalInput<T>().toCollection<T>(destination)
11/**
12 * Consumes this sequence. Appends transformed elements to the destination and returns it.
13 */
14public fun <T, R> Sequence<T>.mapTo(destination: MutableList<R>, transform: (T) -> R): MutableList<R> =
15 terminalInput<T>().mapTo<T, R>(destination, transform)
17/**
18 * Consumes this sequence. Appends matching elements to the destination and returns it.
19 */
20public fun <T> Sequence<T>.filterTo(destination: MutableList<T>, predicate: (T) -> Boolean): MutableList<T> =
21 terminalInput<T>().filterTo<T>(destination, predicate)
23/**
24 * Consumes this sequence. Appends each transformed iterable to the destination and returns it.
25 */
26public fun <T, R> Sequence<T>.flatMapTo(destination: MutableList<R>, transform: (T) -> Sequence<R>): MutableList<R> =
27 terminalInput<T>().flatMapTo<T, R>(destination) { value -> transform(value).terminalInput<R>() }
29/**
30 * Consumes this sequence. Adds all source elements to the destination and returns it.
31 */
32public fun <T> Sequence<T>.toCollection(destination: MutableSet<T>): MutableSet<T> =
33 terminalInput<T>().toCollection<T>(destination)
35/**
36 * Consumes this sequence. Appends transformed elements to the destination and returns it.
37 */
38public fun <T, R> Sequence<T>.mapTo(destination: MutableSet<R>, transform: (T) -> R): MutableSet<R> =
39 terminalInput<T>().mapTo<T, R>(destination, transform)
41/**
42 * Consumes this sequence. Appends matching elements to the destination and returns it.
43 */
44public fun <T> Sequence<T>.filterTo(destination: MutableSet<T>, predicate: (T) -> Boolean): MutableSet<T> =
45 terminalInput<T>().filterTo<T>(destination, predicate)
47/**
48 * Consumes this sequence. Appends each transformed iterable to the destination and returns it.
49 */
50public fun <T, R> Sequence<T>.flatMapTo(destination: MutableSet<R>, transform: (T) -> Sequence<R>): MutableSet<R> =
51 terminalInput<T>().flatMapTo<T, R>(destination) { value -> transform(value).terminalInput<R>() }