Managed vectors
append
build
- Builds a vector by calling a provided function with an argument function that pushes an element to the back of a vector.build_sized
- Builds a vector by calling a provided function with an argument function that pushes an element to the back of a vectorbuild_sized_opt
- Builds a vector by calling a provided function with an argument function that pushes an element to the back of a vectorcapacity
- 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 resultsat_vec::raw
at_vec::rusti
at_vec::rustrt
- Code for dealing with @-vectorsappend
fn append<T: Copy>(lhs: @[T], rhs: &[const T]) -> @[T]
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.
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.
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.
capacity
fn capacity<T>(v: @[const 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: 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
.
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