Managed vectors

Function append

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

Iterates over the rhs vector, copying each element and appending it to the lhs. Afterwards, the lhs is then returned for use again.

Function build

fn build<A>(builder: &fn(push: &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: &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: &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: @[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: &fn(uint) -> 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

Function to_managed

fn to_managed<T: Copy>(v: &[T]) -> @[T]

Creates and initializes an immutable managed vector by copying all the elements of a slice.

Function to_managed_consume

fn to_managed_consume<T>(v: ~[T]) -> @[T]

Creates and initializes an immutable managed vector by moving all the elements from an owned vector.