scoop:scoop.std:0.1.0
src/sequences/terminal_find.scoop
Selected production source · src/sequences/terminal_find.scoop
1
package scoop.sequences3
import scoop.collections.*5
/**6
* Consumes this sequence. Returns the first eligible element in iteration order, applying the7
* predicate when supplied; absence throws NoSuchElementException.8
*/9
public fun <T> Sequence<T>.first(): T =10
terminalInput<T>().first<T>()12
/**13
* Consumes this sequence. Returns the first eligible element in iteration order, applying the14
* predicate when supplied; absence throws NoSuchElementException.15
*/16
public fun <T> Sequence<T>.first(predicate: (T) -> Boolean): T =17
terminalInput<T>().first<T>(predicate)19
/**20
* Consumes this sequence. Returns the first eligible element in iteration order, applying the21
* predicate when supplied, or None.22
*/23
public fun <T> Sequence<T>.firstOrNone(): T? =24
terminalInput<T>().firstOrNone<T>()26
/**27
* Consumes this sequence. Returns the first eligible element in iteration order, applying the28
* predicate when supplied, or None.29
*/30
public fun <T> Sequence<T>.firstOrNone(predicate: (T) -> Boolean): T? =31
terminalInput<T>().firstOrNone<T>(predicate)33
/**34
* Consumes this sequence. Returns the last eligible element after traversal, applying the35
* predicate when supplied; absence throws NoSuchElementException.36
*/37
public fun <T> Sequence<T>.last(): T =38
terminalInput<T>().last<T>()40
/**41
* Consumes this sequence. Returns the last eligible element after traversal, applying the42
* predicate when supplied; absence throws NoSuchElementException.43
*/44
public fun <T> Sequence<T>.last(predicate: (T) -> Boolean): T =45
terminalInput<T>().last<T>(predicate)47
/**48
* Consumes this sequence. Returns the last eligible element after traversal, applying the49
* predicate when supplied, or None.50
*/51
public fun <T> Sequence<T>.lastOrNone(): T? =52
terminalInput<T>().lastOrNone<T>()54
/**55
* Consumes this sequence. Returns the last eligible element after traversal, applying the56
* predicate when supplied, or None.57
*/58
public fun <T> Sequence<T>.lastOrNone(predicate: (T) -> Boolean): T? =59
terminalInput<T>().lastOrNone<T>(predicate)61
/**62
* Consumes this sequence. Requires exactly one eligible element. No match throws63
* NoSuchElementException; multiple matches throw IllegalArgumentException.64
*/65
public fun <T> Sequence<T>.single(): T =66
terminalInput<T>().single<T>()68
/**69
* Consumes this sequence. Requires exactly one eligible element. No match throws70
* NoSuchElementException; multiple matches throw IllegalArgumentException.71
*/72
public fun <T> Sequence<T>.single(predicate: (T) -> Boolean): T =73
terminalInput<T>().single<T>(predicate)75
/**76
* Consumes this sequence. Returns the sole eligible element, or None for zero or multiple matches.77
*/78
public fun <T> Sequence<T>.singleOrNone(): T? =79
terminalInput<T>().singleOrNone<T>()81
/**82
* Consumes this sequence. Returns the sole eligible element, or None for zero or multiple matches.83
*/84
public fun <T> Sequence<T>.singleOrNone(predicate: (T) -> Boolean): T? =85
terminalInput<T>().singleOrNone<T>(predicate)87
/**88
* Consumes this sequence. Returns the first element satisfying the predicate, or None.89
*/90
public fun <T> Sequence<T>.find(predicate: (T) -> Boolean): T? =91
terminalInput<T>().find<T>(predicate)93
/**94
* Consumes this sequence. Returns the element at a zero-based iteration index; an out-of-range95
* index throws IndexOutOfBoundsException.96
*/97
public fun <T> Sequence<T>.elementAt(index: Long): T =98
terminalInput<T>().elementAt<T>(index)100
/**101
* Consumes this sequence. Returns the element at a zero-based iteration index, or None for a102
* negative or out-of-range index.103
*/104
public fun <T> Sequence<T>.elementAtOrNone(index: Long): T? =105
terminalInput<T>().elementAtOrNone<T>(index)107
/**108
* Consumes this sequence. Returns the first equal element's zero-based iteration index, or -1 if109
* absent.110
*/111
public fun <T : Equals<T>> Sequence<T>.indexOf(element: T): Long =112
terminalInput<T>().indexOf<T>(element)114
/**115
* Consumes this sequence. Stops at the first equal element and reports whether one exists.116
*/117
public operator fun <T : Equals<T>> Sequence<T>.contains(element: T): Boolean =118
terminalInput<T>().contains<T>(element)