Managed vectors
append
- Iterates over the rhs
vector, copying each element and appending it to the lhs
build
build_sized
build_sized_opt
capacity
- Returns the number of elements the vector can hold without reallocatingfrom_elem
- Creates and initializes an immutable vector.from_fn
- Creates and initializes an immutable vector.map
- Apply a function to each element of a vector and return the resultsto_managed
- Creates and initializes an immutable managed vector by copying all the elements of a slice.to_managed_consume
- Creates and initializes an immutable managed vector by moving all the elements from an owned vector.at_vec::raw
at_vec::rustrt
- Code for dealing with @-vectorsat_vec::traits
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.
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.
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.
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.
capacity
fn capacity<T>(v: @[T]) -> uint
Returns the number of elements the vector can hold without reallocating
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
.
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
.
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
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.
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.