stdlib.iter¶
Iterator Library
Generated from
v0.60.1. 7 source files, 196 documented symbols.
chain.xi¶
fn iter_fold(v: &Vec[Int], init: Int, f: fn(Int, &Int) -> Int) -> Int¶
Left fold over v with seed init: acc = f(acc, v[i]) for i in order. Returns the final accumulator. O(n). The combiner takes (acc, element).
fn iter_fold_right(v: &Vec[Int], init: Int, f: fn(Int, &Int) -> Int) -> Int¶
Right fold over v with seed init: acc = f(acc, v[i]) visiting elements from the last to the first. Returns the final accumulator. O(n).
fn iter_reduce(v: &Vec[Int], f: fn(&Int, &Int) -> Int) -> Option[Int]¶
Fold using the first element as the seed; None if v is empty. O(n).
fn iter_sum(v: &Vec[Int]) -> Int¶
Sum of all elements of an Int vector. O(n). Empty vector sums to 0.
fn iter_product(v: &Vec[Int]) -> Int¶
Product of all elements of an Int vector. O(n). Empty vector is 1.
fn iter_any(v: &Vec[Int], pred: fn(&Int) -> Bool) -> Bool¶
True if any element satisfies pred. O(n). Short-circuits.
fn iter_all(v: &Vec[Int], pred: fn(&Int) -> Bool) -> Bool¶
True if every element satisfies pred. O(n). Short-circuits.
fn iter_count(v: &Vec[Int]) -> Int¶
Number of elements in v. O(1).
- Postcondition:
result == v.len()
fn iter_count_if(v: &Vec[Int], pred: fn(&Int) -> Bool) -> Int¶
Number of elements satisfying pred. O(n).
- Postcondition:
result >= 0 && result <= v.len()
fn iter_nth(v: &Vec[Int], n: Int) -> Option[Int]¶
Element at index n, or None if out of bounds. O(1).
fn iter_last(v: &Vec[Int]) -> Option[Int]¶
Last element of v, or None if empty. O(1).
fn iter_position(v: &Vec[Int], pred: fn(&Int) -> Bool) -> Option[Int]¶
Index of the first element satisfying pred, or None. O(n).
fn iter_max(v: &Vec[Int]) -> Option[Int]¶
Maximum element of an Int vector, or None if empty. O(n).
fn iter_min(v: &Vec[Int]) -> Option[Int]¶
Minimum element of an Int vector, or None if empty. O(n).
fn iter_partition(v: &Vec[Int], pred: fn(&Int) -> Bool) -> (Vec[Int], Vec[Int])¶
Split v into (matching, non-matching) vectors by pred. O(n). The first tuple element holds elements where pred is true, in order.
fn iter_group_by(v: &Vec[Int], key: fn(&Int) -> Int) -> Vec[Vec[Int]]¶
Split v into contiguous groups of elements sharing an equal key value. Returns a vector of groups in original order. O(n). NOTE: nested Vec[Vec[Int]] element access is unreliable in the current compiler; treat the result as opaque and inspect group lengths only.
filter.xi¶
fn iter_filter(v: &Vec[Int], pred: fn(&Int) -> Bool) -> Vec[Int]¶
New vector with the elements of v satisfying pred, in order. O(n).
- Postcondition:
result.len() <= v.len()
fn iter_filter_mut(v: &mut Vec[Int], pred: fn(&Int) -> Bool)¶
Remove in place every element of v not satisfying pred. O(n). Element order is preserved; v is compacted in place.
fn iter_take(v: &Vec[Int], n: Int) -> Vec[Int]¶
First n elements of v (or fewer if v is shorter). O(n). n <= 0 yields an empty vector.
- Postcondition:
result.len() <= v.len()
fn iter_skip(v: &Vec[Int], n: Int) -> Vec[Int]¶
All elements of v after the first n. O(n). n <= 0 returns all of v.
- Postcondition:
result.len() <= v.len()
fn iter_take_while(v: &Vec[Int], pred: fn(&Int) -> Bool) -> Vec[Int]¶
The leading run of elements for which pred holds. O(n). Short-circuits.
fn iter_skip_while(v: &Vec[Int], pred: fn(&Int) -> Bool) -> Vec[Int]¶
Elements of v after the leading run satisfying pred. O(n). Short-circuits.
fn iter_dedup(v: &Vec[Int]) -> Vec[Int]¶
Drop consecutive equal elements from v. O(n). [1,1,2,2,3,1] -> [1,2,3,1].
- Postcondition:
result.len() <= v.len()
fn iter_unique(v: &Vec[Int]) -> Vec[Int]¶
Keep the first occurrence of each value, dropping later duplicates. O(n^2).
- Postcondition:
result.len() <= v.len()
fold.xi¶
fn iter_fold1(v: &Vec[Int], f: fn(&Int, &Int) -> Int) -> Option[Int]¶
Fold without a seed using the first element, or None if v is empty. O(n). f(acc, element) returns the next accumulator.
- Postcondition:
v.len() == 0 => result is None - Postcondition:
result is Some(_) => v.len() > 0
fn iter_scan(v: &Vec[Int], init: Int, f: fn(Int, &Int) -> Int) -> Vec[Int]¶
Running-accumulator fold emitting every intermediate state. O(n). The result starts with init, followed by each new accumulator, so it always has v.len() + 1 elements.
- Postcondition:
result.len() == v.len() + 1
fn iter_find(v: &Vec[Int], pred: fn(&Int) -> Bool) -> Option[Int]¶
First element satisfying pred, or None. O(n). Short-circuits.
fn iter_find_map(v: &Vec[Int], f: fn(&Int) -> Option[Int]) -> Option[Int]¶
First Some value produced by f over the elements, or None. O(n). Short-circuits on the first Some result.
fn iter_contains(v: &Vec[Int], item: Int) -> Bool¶
True if item occurs in v. O(n).
fn iter_position_of(v: &Vec[Int], item: Int) -> Option[Int]¶
Index of the first occurrence of item, or None. O(n).
fn iter_chunks(v: &Vec[Int], n: Int) -> Vec[Vec[Int]]¶
Contiguous non-overlapping chunks of size n; the last chunk may be short. O(n). n <= 0 yields an empty vector. Returns Vec[Vec[Int]]; nested element access is unreliable in the current compiler - treat as opaque.
fn iter_windows(v: &Vec[Int], n: Int) -> Vec[Vec[Int]]¶
All contiguous length-n slices of v. O(n * w). Returns Vec[Vec[Int]]; nested element access is unreliable in the current compiler. An empty result means n <= 0 or n > v.len().
fn iter_cycle(v: &Vec[Int], n: Int) -> Vec[Int]¶
v repeated n times concatenated. O(n * v.len()). n <= 0 yields empty.
- Postcondition:
n >= 0 => result.len() == v.len() * n - Postcondition:
n < 0 => result.len() == 0
fn iter_repeat(item: Int, n: Int) -> Vec[Int]¶
item repeated n times. O(n). n <= 0 yields an empty vector.
- Postcondition:
n >= 0 => result.len() == n - Postcondition:
n < 0 => result.len() == 0
fn iter_reverse(v: &Vec[Int]) -> Vec[Int]¶
Elements of v in reverse order. O(n).
- Postcondition:
result.len() == v.len()
fn iter_sort(v: &Vec[Int]) -> Vec[Int]¶
Sorted copy of v. O(n log n), stable.
- Postcondition:
result.len() == v.len()
fn iter_for_each(v: &Vec[Int], f: fn(&Int) -> Unit)¶
Apply f to each element for side effects. O(n).
fn iter_cmp(a: &Vec[Int], b: &Vec[Int]) -> Int¶
Lexicographic comparison of a and b: -1, 0, or 1. O(min(len)). A prefix of the other compares smaller.
fn iter_eq(a: &Vec[Int], b: &Vec[Int]) -> Bool¶
Element-wise equality of a and b (lengths must match). O(n).
iter.xi¶
type Range¶
=== Range types === Half-open integer range [start, end).
| Field | Type |
|---|---|
start |
Int |
end |
Int |
type RangeInclusive¶
Inclusive integer range [start, end] with cursor state.
| Field | Type |
|---|---|
start |
Int |
end |
Int |
current |
Int |
done |
Bool |
fn range(start: Int, end: Int) -> Range¶
Create a half-open range [start, end).
fn range_inclusive(start: Int, end: Int) -> RangeInclusive¶
Create an inclusive range [start, end].
fn next(self: Self) -> Option[Int]¶
Yield the next integer; None once
start >= end. Consumes from the front.
- Postcondition:
true
fn len(self: Self) -> Int¶
Number of integers left in the range.
- Postcondition:
result >= 0
fn contains(self: Self, x: Int) -> Bool¶
True when
xis inside [start, end); does not consume the range.
fn sum(self: Self) -> Int¶
Sum of the remaining integers (0 for an empty range).
fn product(self: Self) -> Int¶
Product of the remaining integers (1 for an empty range).
fn next(self: Self) -> Option[Int]¶
Yield the next integer; None after the inclusive end was reached.
fn map[U](self: Self, f: fn(Int) -> U) -> MapIter[Int, U]¶
Lazily apply
fto each integer in the range.
fn filter(self: Self, predicate: fn(&Int) -> Bool) -> FilterIter[Int]¶
Lazily keep only integers satisfying
predicate.
fn enumerate(self: Self) -> EnumerateIter[Int]¶
Pair each integer with its 0-based position.
fn take(self: Self, n: Int) -> TakeIter[Int]¶
Yield at most the first
nintegers.
fn skip(self: Self, n: Int) -> SkipIter[Int]¶
Skip the first
nintegers.
fn chain(self: Self, other: Range) -> ChainIter[Int, Int]¶
Continue with the integers of
otherafter this range ends.
fn zip(self: Self, other: Range) -> ZipIter[Int, Int]¶
Pair integers with
otheruntil either runs out.
fn collect(self: Self) -> Vec[Int]¶
Drain the remaining integers into a Vec.
fn fold[B](self: Self, init: B, f: fn(B, Int) -> B) -> B¶
Fold the remaining integers with
f, starting frominit.
fn count(self: Self) -> Int¶
Number of remaining integers.
fn max(self: Self) -> Option[Int]¶
Largest remaining integer, or None for an empty range.
fn min(self: Self) -> Option[Int]¶
Smallest remaining integer, or None for an empty range.
fn find(self: Self, predicate: fn(&Int) -> Bool) -> Option[Int]¶
First remaining integer satisfying
predicate, or None.
fn all(self: Self, predicate: fn(&Int) -> Bool) -> Bool¶
True when every remaining integer satisfies
predicate.
fn any(self: Self, predicate: fn(&Int) -> Bool) -> Bool¶
True when at least one remaining integer satisfies
predicate.
fn nth(self: Self, n: Int) -> Option[Int]¶
Skip to and return the
n-th remaining integer (0-based), or None.
fn last(self: Self) -> Option[Int]¶
Consume and return the final integer, or None for an empty range.
type MapIter¶
Lazy map iterator, produced by
map.
| Field | Type |
|---|---|
next_fn |
fn() -> Option[T] |
f |
fn(T) -> U |
type FilterIter¶
Lazy filter iterator, produced by
filter.
| Field | Type |
|---|---|
next_fn |
fn() -> Option[T] |
predicate |
fn(&T) -> Bool |
type EnumerateIter¶
Iterator pairing elements with a 0-based index.
| Field | Type |
|---|---|
next_fn |
fn() -> Option[T] |
index |
Int |
type TakeIter¶
Iterator yielding at most a fixed number of elements.
| Field | Type |
|---|---|
next_fn |
fn() -> Option[T] |
remaining |
Int |
type SkipIter¶
Iterator skipping a fixed number of leading elements.
| Field | Type |
|---|---|
next_fn |
fn() -> Option[T] |
to_skip |
Int |
type ChainIter¶
Iterator continuing with a second iterator after the first ends.
| Field | Type |
|---|---|
next_fn |
fn() -> Option[T] |
second |
fn() -> Option[U] |
type ZipIter¶
Iterator pairing elements of two iterators.
| Field | Type |
|---|---|
a |
fn() -> Option[T] |
b |
fn() -> Option[U] |
fn next[T, U](self: Self) -> Option[U]¶
Generated summary: Method; Takes no arguments; returns Option[U]. No source comment yet.
fn next[T](self: Self) -> Option[T]¶
Generated summary: Method; Takes no arguments; returns Option[T]. No source comment yet.
fn next[T](self: Self) -> Option[(Int, T)]¶
Generated summary: Method; Takes no arguments; returns Option[(Int, T)]. No source comment yet.
fn next[T](self: Self) -> Option[T]¶
Generated summary: Method; Takes no arguments; returns Option[T]. No source comment yet.
fn next[T](self: Self) -> Option[T]¶
Generated summary: Method; Takes no arguments; returns Option[T]. No source comment yet.
fn next[T, U](self: Self) -> Option[T]¶
Generated summary: Method; Takes no arguments; returns Option[T]. No source comment yet.
fn next[T, U](self: Self) -> Option[(T, U)]¶
Generated summary: Method; Takes no arguments; returns Option[(T, U)]. No source comment yet.
fn map[T, U, V](self: Self, f: fn(U) -> V) -> MapIter[U, V]¶
Generated summary: Method; takes f: fn(U) -> V; returns MapIter[U, V]. No source comment yet.
fn filter[T, U](self: Self, predicate: fn(&U) -> Bool) -> FilterIter[U]¶
Generated summary: Method; takes predicate: fn(&U) -> Bool; returns FilterIter[U]. No source comment yet.
fn enumerate[T, U](self: Self) -> EnumerateIter[U]¶
Generated summary: Method; Takes no arguments; returns EnumerateIter[U]. No source comment yet.
fn take[T, U](self: Self, n: Int) -> TakeIter[U]¶
Generated summary: Method; takes n: Int; returns TakeIter[U]. No source comment yet.
fn skip[T, U](self: Self, n: Int) -> SkipIter[U]¶
Generated summary: Method; takes n: Int; returns SkipIter[U]. No source comment yet.
fn chain[T, U](self: Self, other: Range) -> ChainIter[U, Int]¶
Generated summary: Method; takes other: Range; returns ChainIter[U, Int]. No source comment yet.
fn zip[T, U](self: Self, other: Range) -> ZipIter[U, Int]¶
Generated summary: Method; takes other: Range; returns ZipIter[U, Int]. No source comment yet.
fn collect[T, U](self: Self) -> Vec[U]¶
Generated summary: Method; Takes no arguments; returns Vec[U]. No source comment yet.
fn fold[T, U, B](self: Self, init: B, f: fn(B, U) -> B) -> B¶
Generated summary: Method; takes init: B, f: fn(B, U) -> B; returns B. No source comment yet.
fn count[T, U](self: Self) -> Int¶
Generated summary: Method; Takes no arguments; returns Int. No source comment yet.
fn sum[T, U](self: Self) -> U¶
Generated summary: Method; Takes no arguments; returns U. No source comment yet.
fn product[T, U](self: Self) -> U¶
Generated summary: Method; Takes no arguments; returns U. No source comment yet.
fn max[T, U](self: Self) -> Option[U]¶
Generated summary: Method; Takes no arguments; returns Option[U]. No source comment yet.
fn min[T, U](self: Self) -> Option[U]¶
Generated summary: Method; Takes no arguments; returns Option[U]. No source comment yet.
fn find[T, U](self: Self, predicate: fn(&U) -> Bool) -> Option[U]¶
Generated summary: Method; takes predicate: fn(&U) -> Bool; returns Option[U]. No source comment yet.
fn all[T, U](self: Self, predicate: fn(&U) -> Bool) -> Bool¶
Generated summary: Method; takes predicate: fn(&U) -> Bool; returns Bool. No source comment yet.
fn any[T, U](self: Self, predicate: fn(&U) -> Bool) -> Bool¶
Generated summary: Method; takes predicate: fn(&U) -> Bool; returns Bool. No source comment yet.
fn nth[T, U](self: Self, n: Int) -> Option[U]¶
Generated summary: Method; takes n: Int; returns Option[U]. No source comment yet.
fn last[T, U](self: Self) -> Option[U]¶
Generated summary: Method; Takes no arguments; returns Option[U]. No source comment yet.
fn map[T, U](self: Self, f: fn(T) -> U) -> MapIter[T, U]¶
Generated summary: Method; takes f: fn(T) -> U; returns MapIter[T, U]. No source comment yet.
fn filter[T](self: Self, predicate: fn(&T) -> Bool) -> FilterIter[T]¶
Generated summary: Method; takes predicate: fn(&T) -> Bool; returns FilterIter[T]. No source comment yet.
fn enumerate[T](self: Self) -> EnumerateIter[T]¶
Generated summary: Method; Takes no arguments; returns EnumerateIter[T]. No source comment yet.
fn take[T](self: Self, n: Int) -> TakeIter[T]¶
Generated summary: Method; takes n: Int; returns TakeIter[T]. No source comment yet.
fn skip[T](self: Self, n: Int) -> SkipIter[T]¶
Generated summary: Method; takes n: Int; returns SkipIter[T]. No source comment yet.
fn chain[T](self: Self, other: Range) -> ChainIter[T, Int]¶
Generated summary: Method; takes other: Range; returns ChainIter[T, Int]. No source comment yet.
fn zip[T](self: Self, other: Range) -> ZipIter[T, Int]¶
Generated summary: Method; takes other: Range; returns ZipIter[T, Int]. No source comment yet.
fn collect[T](self: Self) -> Vec[T]¶
Generated summary: Method; Takes no arguments; returns Vec[T]. No source comment yet.
fn fold[T, B](self: Self, init: B, f: fn(B, T) -> B) -> B¶
Generated summary: Method; takes init: B, f: fn(B, T) -> B; returns B. No source comment yet.
fn count[T](self: Self) -> Int¶
Generated summary: Method; Takes no arguments; returns Int. No source comment yet.
fn sum[T](self: Self) -> T¶
Generated summary: Method; Takes no arguments; returns T. No source comment yet.
fn product[T](self: Self) -> T¶
Generated summary: Method; Takes no arguments; returns T. No source comment yet.
fn max[T](self: Self) -> Option[T]¶
Generated summary: Method; Takes no arguments; returns Option[T]. No source comment yet.
fn min[T](self: Self) -> Option[T]¶
Generated summary: Method; Takes no arguments; returns Option[T]. No source comment yet.
fn find[T](self: Self, predicate: fn(&T) -> Bool) -> Option[T]¶
Generated summary: Method; takes predicate: fn(&T) -> Bool; returns Option[T]. No source comment yet.
fn all[T](self: Self, predicate: fn(&T) -> Bool) -> Bool¶
Generated summary: Method; takes predicate: fn(&T) -> Bool; returns Bool. No source comment yet.
fn any[T](self: Self, predicate: fn(&T) -> Bool) -> Bool¶
Generated summary: Method; takes predicate: fn(&T) -> Bool; returns Bool. No source comment yet.
fn nth[T](self: Self, n: Int) -> Option[T]¶
Generated summary: Method; takes n: Int; returns Option[T]. No source comment yet.
fn last[T](self: Self) -> Option[T]¶
Generated summary: Method; Takes no arguments; returns Option[T]. No source comment yet.
fn map[T, U](self: Self, f: fn((Int, T)) -> U) -> MapIter[(Int, T), U]¶
Generated summary: Method; takes f: fn((Int, T)) -> U; returns MapIter[(Int, T), U]. No source comment yet.
fn take[T](self: Self, n: Int) -> TakeIter[(Int, T)]¶
Generated summary: Method; takes n: Int; returns TakeIter[(Int, T)]. No source comment yet.
fn collect[T](self: Self) -> Vec[(Int, T)]¶
Generated summary: Method; Takes no arguments; returns Vec[(Int, T)]. No source comment yet.
fn count[T](self: Self) -> Int¶
Generated summary: Method; Takes no arguments; returns Int. No source comment yet.
fn map[T, U](self: Self, f: fn(T) -> U) -> MapIter[T, U]¶
Generated summary: Method; takes f: fn(T) -> U; returns MapIter[T, U]. No source comment yet.
fn filter[T](self: Self, predicate: fn(&T) -> Bool) -> FilterIter[T]¶
Generated summary: Method; takes predicate: fn(&T) -> Bool; returns FilterIter[T]. No source comment yet.
fn collect[T](self: Self) -> Vec[T]¶
Generated summary: Method; Takes no arguments; returns Vec[T]. No source comment yet.
fn fold[T, B](self: Self, init: B, f: fn(B, T) -> B) -> B¶
Generated summary: Method; takes init: B, f: fn(B, T) -> B; returns B. No source comment yet.
fn count[T](self: Self) -> Int¶
Generated summary: Method; Takes no arguments; returns Int. No source comment yet.
fn sum[T](self: Self) -> T¶
Generated summary: Method; Takes no arguments; returns T. No source comment yet.
fn product[T](self: Self) -> T¶
Generated summary: Method; Takes no arguments; returns T. No source comment yet.
fn max[T](self: Self) -> Option[T]¶
Generated summary: Method; Takes no arguments; returns Option[T]. No source comment yet.
fn min[T](self: Self) -> Option[T]¶
Generated summary: Method; Takes no arguments; returns Option[T]. No source comment yet.
fn find[T](self: Self, predicate: fn(&T) -> Bool) -> Option[T]¶
Generated summary: Method; takes predicate: fn(&T) -> Bool; returns Option[T]. No source comment yet.
fn all[T](self: Self, predicate: fn(&T) -> Bool) -> Bool¶
Generated summary: Method; takes predicate: fn(&T) -> Bool; returns Bool. No source comment yet.
fn any[T](self: Self, predicate: fn(&T) -> Bool) -> Bool¶
Generated summary: Method; takes predicate: fn(&T) -> Bool; returns Bool. No source comment yet.
fn nth[T](self: Self, n: Int) -> Option[T]¶
Generated summary: Method; takes n: Int; returns Option[T]. No source comment yet.
fn last[T](self: Self) -> Option[T]¶
Generated summary: Method; Takes no arguments; returns Option[T]. No source comment yet.
fn map[T, U](self: Self, f: fn(T) -> U) -> MapIter[T, U]¶
Generated summary: Method; takes f: fn(T) -> U; returns MapIter[T, U]. No source comment yet.
fn filter[T](self: Self, predicate: fn(&T) -> Bool) -> FilterIter[T]¶
Generated summary: Method; takes predicate: fn(&T) -> Bool; returns FilterIter[T]. No source comment yet.
fn collect[T](self: Self) -> Vec[T]¶
Generated summary: Method; Takes no arguments; returns Vec[T]. No source comment yet.
fn fold[T, B](self: Self, init: B, f: fn(B, T) -> B) -> B¶
Generated summary: Method; takes init: B, f: fn(B, T) -> B; returns B. No source comment yet.
fn count[T](self: Self) -> Int¶
Generated summary: Method; Takes no arguments; returns Int. No source comment yet.
fn sum[T](self: Self) -> T¶
Generated summary: Method; Takes no arguments; returns T. No source comment yet.
fn product[T](self: Self) -> T¶
Generated summary: Method; Takes no arguments; returns T. No source comment yet.
fn max[T](self: Self) -> Option[T]¶
Generated summary: Method; Takes no arguments; returns Option[T]. No source comment yet.
fn min[T](self: Self) -> Option[T]¶
Generated summary: Method; Takes no arguments; returns Option[T]. No source comment yet.
fn find[T](self: Self, predicate: fn(&T) -> Bool) -> Option[T]¶
Generated summary: Method; takes predicate: fn(&T) -> Bool; returns Option[T]. No source comment yet.
fn all[T](self: Self, predicate: fn(&T) -> Bool) -> Bool¶
Generated summary: Method; takes predicate: fn(&T) -> Bool; returns Bool. No source comment yet.
fn any[T](self: Self, predicate: fn(&T) -> Bool) -> Bool¶
Generated summary: Method; takes predicate: fn(&T) -> Bool; returns Bool. No source comment yet.
fn nth[T](self: Self, n: Int) -> Option[T]¶
Generated summary: Method; takes n: Int; returns Option[T]. No source comment yet.
fn last[T](self: Self) -> Option[T]¶
Generated summary: Method; Takes no arguments; returns Option[T]. No source comment yet.
fn collect[T, U](self: Self) -> Vec[T]¶
Generated summary: Method; Takes no arguments; returns Vec[T]. No source comment yet.
fn count[T, U](self: Self) -> Int¶
Generated summary: Method; Takes no arguments; returns Int. No source comment yet.
fn map[T, U, V](self: Self, f: fn(T) -> V) -> MapIter[T, V]¶
Generated summary: Method; takes f: fn(T) -> V; returns MapIter[T, V]. No source comment yet.
fn take[T, U](self: Self, n: Int) -> TakeIter[T]¶
Generated summary: Method; takes n: Int; returns TakeIter[T]. No source comment yet.
fn find[T, U](self: Self, predicate: fn(&T) -> Bool) -> Option[T]¶
Generated summary: Method; takes predicate: fn(&T) -> Bool; returns Option[T]. No source comment yet.
fn all[T, U](self: Self, predicate: fn(&T) -> Bool) -> Bool¶
Generated summary: Method; takes predicate: fn(&T) -> Bool; returns Bool. No source comment yet.
fn any[T, U](self: Self, predicate: fn(&T) -> Bool) -> Bool¶
Generated summary: Method; takes predicate: fn(&T) -> Bool; returns Bool. No source comment yet.
fn nth[T, U](self: Self, n: Int) -> Option[T]¶
Generated summary: Method; takes n: Int; returns Option[T]. No source comment yet.
fn last[T, U](self: Self) -> Option[T]¶
Generated summary: Method; Takes no arguments; returns Option[T]. No source comment yet.
fn collect[T, U](self: Self) -> Vec[(T, U)]¶
Generated summary: Method; Takes no arguments; returns Vec[(T, U)]. No source comment yet.
fn count[T, U](self: Self) -> Int¶
Generated summary: Method; Takes no arguments; returns Int. No source comment yet.
fn find[T, U](self: Self, predicate: fn(&(T, U)) -> Bool) -> Option[(T, U)]¶
Generated summary: Method; takes predicate: fn(&(T, U)) -> Bool; returns Option[(T, U)]. No source comment yet.
fn all[T, U](self: Self, predicate: fn(&(T, U)) -> Bool) -> Bool¶
Generated summary: Method; takes predicate: fn(&(T, U)) -> Bool; returns Bool. No source comment yet.
fn any[T, U](self: Self, predicate: fn(&(T, U)) -> Bool) -> Bool¶
Generated summary: Method; takes predicate: fn(&(T, U)) -> Bool; returns Bool. No source comment yet.
fn nth[T, U](self: Self, n: Int) -> Option[(T, U)]¶
Generated summary: Method; takes n: Int; returns Option[(T, U)]. No source comment yet.
fn last[T, U](self: Self) -> Option[(T, U)]¶
Generated summary: Method; Takes no arguments; returns Option[(T, U)]. No source comment yet.
type StepByIter¶
StepBy -- yields every nth element (1-based step) Iterator taking every
step-th element of an underlying iterator.
| Field | Type |
|---|---|
iter |
Iterator[T] |
step |
Int |
first |
Bool |
fn step_by[T](self: Self, step: Int) -> StepByIter[T]¶
Generated summary: Method; takes step: Int; returns StepByIter[T]. No source comment yet.
- Precondition:
step > 0
fn next[T](self: Self) -> Option[T]¶
Generated summary: Method; Takes no arguments; returns Option[T]. No source comment yet.
- Postcondition:
true
type TakeWhileIter¶
TakeWhile -- yields elements while predicate is true Iterator yielding elements while a predicate holds.
| Field | Type |
|---|---|
iter |
Iterator[T] |
predicate |
fn(&T) -> Bool |
done |
Bool |
fn take_while[T](self: Self, predicate: fn(&T) -> Bool) -> TakeWhileIter[T]¶
Generated summary: Method; takes predicate: fn(&T) -> Bool; returns TakeWhileIter[T]. No source comment yet.
fn next[T](self: Self) -> Option[T]¶
Generated summary: Method; Takes no arguments; returns Option[T]. No source comment yet.
- Postcondition:
self.done => result is None
type SkipWhileIter¶
SkipWhile -- skips elements while predicate is true, then yields rest Iterator skipping elements while a predicate holds.
| Field | Type |
|---|---|
iter |
Iterator[T] |
predicate |
fn(&T) -> Bool |
skipped |
Bool |
fn skip_while[T](self: Self, predicate: fn(&T) -> Bool) -> SkipWhileIter[T]¶
Generated summary: Method; takes predicate: fn(&T) -> Bool; returns SkipWhileIter[T]. No source comment yet.
fn next[T](self: Self) -> Option[T]¶
Generated summary: Method; Takes no arguments; returns Option[T]. No source comment yet.
type InspectIter¶
Inspect -- calls f on each element for side effects, passes element through Iterator running a side effect on each element.
| Field | Type |
|---|---|
iter |
Iterator[T] |
f |
fn(&T) -> Unit |
fn inspect[T](self: Self, f: fn(&T) -> Unit) -> InspectIter[T]¶
Generated summary: Method; takes f: fn(&T) -> Unit; returns InspectIter[T]. No source comment yet.
fn next[T](self: Self) -> Option[T]¶
Generated summary: Method; Takes no arguments; returns Option[T]. No source comment yet.
fn range_step(start: Int, end: Int, step: Int) -> Vec[Int]¶
Create a Vec[Int] containing values from start to end advancing by step. Returns empty Vec if step <= 0 or start >= end. O(N). Collect [start, end) stepping by
stepinto a Vec (empty when step <= 0).
fn repeat_n(value: Int, n: Int) -> Vec[Int]¶
Create a Vec[Int] containing
valuerepeatedntimes. O(N). Returns empty Vec if n <= 0. Vec withvaluerepeatedntimes (empty when n <= 0).
map.xi¶
fn iter_map(v: &Vec[Int], f: fn(&Int) -> Int) -> Vec[Int]¶
Apply f to every element of v, producing a new vector. O(n).
fn iter_flat_map(v: &Vec[Int], f: fn(&Int) -> Vec[Int]) -> Vec[Int]¶
Apply f to every element, then concatenate the result vectors. O(n + m).
fn iter_filter_map(v: &Vec[Int], f: fn(&Int) -> Option[Int]) -> Vec[Int]¶
Keep and unwrap elements where f returns Some. O(n).
fn iter_enumerate(v: &Vec[Int]) -> Vec[(Int, Int)]¶
(index, value) tuple for each element of v. O(n). Returns Vec[(Int, Int)].
fn iter_zip(a: &Vec[Int], b: &Vec[Int]) -> Vec[(Int, Int)]¶
(a[i], b[i]) pairs, truncated to the shorter input. O(min(len)). Returns Vec[(Int, Int)].
range.xi¶
fn range(start: Int, end: Int) -> Vec[Int]¶
Integers in [start, end): start, start+1, ..., end-1. O(n). An empty vector is returned when start >= end.
fn range_step(start: Int, end: Int, step: Int) -> Vec[Int]¶
Integers in [start, end) advancing by step. O(n). An empty vector is returned when step <= 0 or start >= end.
fn range_inclusive(start: Int, end: Int) -> Vec[Int]¶
Integers in [start, end] inclusive of both endpoints. O(n). An empty vector is returned when start > end.
fn range_float(start: Float64, end: Float64, step: Float64) -> Vec[Float64]¶
Float64 values in [start, end) advancing by step. O(n). An empty vector is returned when step <= 0 or start >= end. NOTE (BUG 12): element READS of Vec[Float64] are corrupted by the current compiler; consumers must not index the result until that bug is fixed.
fn range_char(start: Char, end: Char) -> Vec[Char]¶
Characters with code points in [start, end). O(n). An empty vector is returned when start >= end.
fn range_count(n: Int) -> Vec[Int]¶
Integers in [0, n). O(n). An empty vector is returned when n <= 0.
zip.xi¶
fn iter_zip_longest(a: &Vec[Int], b: &Vec[Int], fill: Int) -> Vec[(Int, Int)]¶
(a[i], b[i]) pairs padded with fill on the shorter input, iterating to the length of the longer vector. O(max(len)). Returns Vec[(Int, Int)]. fill is the padding value used for whichever side ran out.
fn iter_chain(a: &Vec[Int], b: &Vec[Int]) -> Vec[Int]¶
Concatenate a followed by b. O(a.len() + b.len()).
fn iter_chain_many(parts: &Vec[Vec[Int]]) -> Vec[Int]¶
Concatenate a list of vectors in order. O(sum of lengths). NOTE: reading elements of the nested Vec[Vec[Int]] is unreliable in the current compiler; prefer iter_chain for two vectors.
fn iter_cartesian_product(a: &Vec[Int], b: &Vec[Int]) -> Vec[(Int, Int)]¶
All (a[i], b[j]) tuple combinations in row-major order. O(len(a) * len(b)). Returns Vec[(Int, Int)].
fn iter_interleave(a: &Vec[Int], b: &Vec[Int]) -> Vec[Int]¶
Alternate elements of a and b: a[0], b[0], a[1], b[1], ... The tail of the longer vector is appended after pairing stops. O(n + m).