The iteration traits and common implementation

Type InitOp

type InitOp<T> = &fn(uint) -> T

A function used to initialize the elements of a sequence

Interface BaseIter

Method each

fn each(blk: &fn(v: &A) -> bool)

Method size_hint

fn size_hint() -> Option<uint>

Interface Buildable

Method build_sized

fn build_sized(size: uint, builder: &fn(push: &pure fn(A))) -> self

Builds a buildable sequence by calling a provided function with an argument function that pushes an element onto the back of the sequence. This version takes an initial size for the sequence.

Arguments

  • size - A hint for an initial size of the sequence
  • builder - A function that will construct the sequence. It recieves as an argument a function that will push an element onto the sequence being constructed.

Interface CopyableIter

Method filter_to_vec

fn filter_to_vec(pred: &fn(&A) -> bool) -> ~[A]

Method to_vec

fn to_vec() -> ~[A]

Method find

fn find(p: &fn(&A) -> bool) -> Option<A>

Interface CopyableNonstrictIter

Method each_val

fn each_val(f: &fn(A) -> bool)

Interface CopyableOrderedIter

Method min

fn min() -> A

Method max

fn max() -> A

Interface EqIter

Method contains

fn contains(x: &A) -> bool

Method count

fn count(x: &A) -> uint

Interface ExtendedIter

Method eachi

fn eachi(blk: &fn(uint, v: &A) -> bool)

Method all

fn all(blk: &fn(&A) -> bool) -> bool

Method any

fn any(blk: &fn(&A) -> bool) -> bool

Method foldl

fn foldl<B>(b0: B, blk: &fn(&B, &A) -> B) -> B

Method position

fn position(f: &fn(&A) -> bool) -> Option<uint>

Method map_to_vec

fn map_to_vec<B>(op: &fn(&A) -> B) -> ~[B]

Method flat_map_to_vec

fn flat_map_to_vec<B, IB: BaseIter<B>>(op: &fn(&A) -> IB) -> ~[B]

Interface Times

Method times

fn times(it: &fn() -> bool)

Function all

fn all<A, IA: BaseIter<A>>(self: &IA, blk: &fn(&A) -> bool) -> bool

Function any

fn any<A, IA: BaseIter<A>>(self: &IA, blk: &fn(&A) -> bool) -> bool

Function append

fn append<T: Copy, IT: BaseIter<T>, BT: Buildable<T>>(lhs: &IT, rhs: &IT) ->
 BT

Appending two generic sequences

Function build

fn build<A, B: Buildable<A>>(builder: &fn(push: &pure fn(A))) -> B

Builds a sequence by calling a provided function with an argument function that pushes an element to the back of a sequence.

Arguments

Function build_sized_opt

fn build_sized_opt<A,
                   B: Buildable<A>>(size: Option<uint>,
                                    builder: &fn(push: &pure fn(A))) -> B

Builds a sequence by calling a provided function with an argument function that pushes an element to the back of a sequence. This version takes an initial size for the sequence.

Arguments

Function contains

fn contains<A: Eq, IA: BaseIter<A>>(self: &IA, x: &A) -> bool

Function copy_seq

fn copy_seq<T: Copy, IT: BaseIter<T>, BT: Buildable<T>>(v: &IT) -> BT

Copies a generic sequence, possibly converting it to a different type of sequence.

Function count

fn count<A: Eq, IA: BaseIter<A>>(self: &IA, x: &A) -> uint

Function eachi

fn eachi<A, IA: BaseIter<A>>(self: &IA, blk: &fn(uint, &A) -> bool)

Function filter_to_vec

fn filter_to_vec<A: Copy, IA: BaseIter<A>>(self: &IA, prd: &fn(&A) -> bool) ->
 ~[A]

Function find

fn find<A: Copy, IA: BaseIter<A>>(self: &IA, f: &fn(&A) -> bool) -> Option<A>

Function flat_map_to_vec

fn flat_map_to_vec<A, B, IA: BaseIter<A>,
                   IB: BaseIter<B>>(self: &IA, op: &fn(&A) -> IB) -> ~[B]

Function foldl

fn foldl<A, B, IA: BaseIter<A>>(self: &IA, b0: B, blk: &fn(&B, &A) -> B) -> B

Function from_elem

fn from_elem<T: Copy, BT: Buildable<T>>(n_elts: uint, t: T) -> BT

Creates and initializes a generic sequence with some element

Creates an immutable vector of size n_elts and initializes the elements to the value t.

Function from_fn

fn from_fn<T, BT: Buildable<T>>(n_elts: uint, op: InitOp<T>) -> BT

Creates and initializes a generic sequence from a function

Creates a generic sequence of size n_elts and initializes the elements to the value returned by the function op.

Function map

fn map<T, IT: BaseIter<T>, U, BU: Buildable<U>>(v: &IT, f: &fn(&T) -> U) -> BU

Apply a function to each element of an iterable and return the results

Function map_to_vec

fn map_to_vec<A, B, IA: BaseIter<A>>(self: &IA, op: &fn(&A) -> B) -> ~[B]

Function max

fn max<A: Copy Ord, IA: BaseIter<A>>(self: &IA) -> A

Function min

fn min<A: Copy Ord, IA: BaseIter<A>>(self: &IA) -> A

Function position

fn position<A, IA: BaseIter<A>>(self: &IA, f: &fn(&A) -> bool) -> Option<uint>

Function repeat

fn repeat(times: uint, blk: &fn() -> bool)

Function to_vec

fn to_vec<A: Copy, IA: BaseIter<A>>(self: &IA) -> ~[A]