std.iter
Iterator interface
pub interface Iterator<T>
mut fn next(): ?T
stdlib/std/iter.lyr:16
RangeIterator class
pub class RangeIterator :: [Iterator<int>]
current: int
end: int
pub mut fn next(): ?int
stdlib/std/iter.lyr:23
ArrayIterator class
pub class ArrayIterator<T> :: [Iterator<T>]
source: T[]
index: int
pub mut fn next(): ?T
stdlib/std/iter.lyr:39
StringIterator class
pub class StringIterator :: [Iterator<char>]
chars: char[]
index: int
pub mut fn next(): ?char
stdlib/std/iter.lyr:56
Iterable interface
pub interface Iterable<T>
fn iter(): Iterator<T>
stdlib/std/iter.lyr:82
MapIterator class
pub class MapIterator<T, U> :: [Iterator<U>]
source: Iterator<T>
f: fn(T) -> U
pub mut fn next(): ?U
stdlib/std/iter.lyr:98
map function
pub fn map<T, U>(source: Iterator<T>, f: fn(T) -> U): Iterator<U>
stdlib/std/iter.lyr:112
FilterIterator class
pub class FilterIterator<T> :: [Iterator<T>]
source: Iterator<T>
keep: fn(T) -> bool
pub mut fn next(): ?T
stdlib/std/iter.lyr:116
filter function
pub fn filter<T>(source: Iterator<T>, keep: fn(T) -> bool): Iterator<T>
stdlib/std/iter.lyr:133
TakeIterator class
pub class TakeIterator<T> :: [Iterator<T>]
source: Iterator<T>
remaining: int
pub mut fn next(): ?T
stdlib/std/iter.lyr:137
take function
pub fn take<T>(source: Iterator<T>, count: int): Iterator<T>
stdlib/std/iter.lyr:152
SkipIterator class
pub class SkipIterator<T> :: [Iterator<T>]
source: Iterator<T>
pending: int
pub mut fn next(): ?T
stdlib/std/iter.lyr:156
skip function
pub fn skip<T>(source: Iterator<T>, count: int): Iterator<T>
stdlib/std/iter.lyr:172
TakeWhileIterator class
pub class TakeWhileIterator<T> :: [Iterator<T>]
source: Iterator<T>
keep: fn(T) -> bool
done: bool
pub mut fn next(): ?T
stdlib/std/iter.lyr:176
takeWhile function
pub fn takeWhile<T>(source: Iterator<T>, keep: fn(T) -> bool): Iterator<T>
stdlib/std/iter.lyr:201
EnumerateIterator class
pub class EnumerateIterator<T> :: [Iterator<(int, T)>]
source: Iterator<T>
index: int
pub mut fn next(): ?(int, T)
stdlib/std/iter.lyr:205
enumerate function
pub fn enumerate<T>(source: Iterator<T>): Iterator<(int, T)>
Numbers the elements: a, b, c becomes (0, a), (1, b), (2, c).
stdlib/std/iter.lyr:221
ZipIterator class
pub class ZipIterator<A, B> :: [Iterator<(A, B)>]
left: Iterator<A>
right: Iterator<B>
pub mut fn next(): ?(A, B)
stdlib/std/iter.lyr:225
zip function
pub fn zip<A, B>(left: Iterator<A>, right: Iterator<B>): Iterator<(A, B)>
Walks both in step and ends with the shorter one.
The one surplus call on left is the price of both sides sharing the same interface; avoiding
it would need a peek on Iterator<T> that exists nowhere else.
stdlib/std/iter.lyr:246
ChainIterator class
pub class ChainIterator<T> :: [Iterator<T>]
first: Iterator<T>
second: Iterator<T>
onFirst: bool
pub mut fn next(): ?T
stdlib/std/iter.lyr:250
chain function
pub fn chain<T>(first: Iterator<T>, second: Iterator<T>): Iterator<T>
stdlib/std/iter.lyr:267
fold function
pub fn fold<T, A>(source: Iterator<T>, seed: A, step: fn(A, T) -> A): A
Folds from the left: fold(1..4, 0, (acc, n) => acc + n) is ((0+1)+2)+3.
The most general terminator; count, sum, any and all are special cases of it. They
exist separately because fold with a closure is too much ceremony for counting.
stdlib/std/iter.lyr:284
count function
pub fn count<T>(source: Iterator<T>): int
stdlib/std/iter.lyr:295
sum function
pub fn sum(source: Iterator<int>): int
stdlib/std/iter.lyr:307
sumFloat function
pub fn sumFloat(source: Iterator<float>): float
stdlib/std/iter.lyr:317
any function
pub fn any<T>(source: Iterator<T>, test: fn(T) -> bool): bool
Stops at the first match; the rest is never evaluated.
stdlib/std/iter.lyr:328
all function
pub fn all<T>(source: Iterator<T>, test: fn(T) -> bool): bool
Stops at the first counterexample. An empty iterator yields true, the only convention for
which all(a) && all(b) == all(chain(a, b)) holds.
stdlib/std/iter.lyr:342
none function
pub fn none<T>(source: Iterator<T>, test: fn(T) -> bool): bool
stdlib/std/iter.lyr:354
find function
pub fn find<T>(source: Iterator<T>, test: fn(T) -> bool): ?T
The first element that matches, or null.
stdlib/std/iter.lyr:359
position function
pub fn position<T>(source: Iterator<T>, test: fn(T) -> bool): ?int
The position of the first match. Separate from find, because a (int, T) tuple would cost
the common case where only one of the two is needed.
stdlib/std/iter.lyr:373
collectArray function
pub fn collectArray<T>(source: Iterator<T>): T[]
Everything into an array.
Quadratic: a T[] has a fixed length, so every append copies. For large iterators use
std.collections.collect, which gathers into a doubling List<T>. It stands here because
std.iter must not import std.collections; the dependency runs the other way.
stdlib/std/iter.lyr:392
minValue function
pub fn minValue<T :: [Ordered<T>]>(source: Iterator<T>): ?T
The smallest element, or null for an empty source.
stdlib/std/iter.lyr:403
maxValue function
pub fn maxValue<T :: [Ordered<T>]>(source: Iterator<T>): ?T
stdlib/std/iter.lyr:418