Managed vectors

Function append

fn append<T: Copy>(lhs: @[T], rhs: &[const T]) -> @[T]

Function build

fn build<A>(builder: &fn(push: &pure fn(v: A))) -> @[A]

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

Arguments

Function build_sized

fn build_sized<A>(size: uint, builder: &fn(push: &pure fn(v: A))) -> @[A]

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

Arguments

Function build_sized_opt

fn build_sized_opt<A>(size: Option<uint>, builder: &fn(push: &pure fn(v: A)))
 -> @[A]

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

Arguments

Function capacity

fn capacity<T>(v: @[const T]) -> uint

Returns the number of elements the vector can hold without reallocating

Function from_elem

fn from_elem<T: Copy>(n_elts: uint, t: T) -> @[T]

Creates and initializes an immutable vector.

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

Function from_fn

fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T]

Creates and initializes an immutable vector.

Creates an immutable vector of size n_elts and initializes the elements to the value returned by the function op.

Function map

fn map<T, U>(v: &[T], f: &fn(x: &T) -> U) -> @[U]

Apply a function to each element of a vector and return the results