Vectors

Struct UnboxedVecRepr

pub struct UnboxedVecRepr {
    mut fill: uint,
    mut alloc: uint,
    data: u8,
}

The internal 'unboxed' representation of a vector

Interface ConstVector

Method is_empty

fn is_empty() -> bool

Method is_not_empty

fn is_not_empty() -> bool

Method len

fn len() -> uint

Interface CopyableVector

Method head

fn head() -> T

Method init

fn init() -> ~[T]

Method last

fn last() -> T

Method slice

fn slice(start: uint, end: uint) -> ~[T]

Method tail

fn tail() -> ~[T]

Interface ImmutableCopyableVector

Method filter

fn filter(f: &fn(t: &T) -> bool) -> ~[T]

Method rfind

fn rfind(f: &fn(t: &T) -> bool) -> Option<T>

Interface ImmutableEqVector

Method position

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

Method position_elem

fn position_elem(t: &T) -> Option<uint>

Method rposition

fn rposition(f: &fn(t: &T) -> bool) -> Option<uint>

Method rposition_elem

fn rposition_elem(t: &T) -> Option<uint>

Interface ImmutableVector

Method view

fn view(start: uint, end: uint) -> &self /[T]

Method foldr

fn foldr<U: Copy>(z: U, p: &fn(t: &T, u: U) -> U) -> U

Method map

fn map<U>(f: &fn(t: &T) -> U) -> ~[U]

Method mapi

fn mapi<U>(f: &fn(uint, t: &T) -> U) -> ~[U]

Method map_r

fn map_r<U>(f: &fn(x: &T) -> U) -> ~[U]

Method alli

fn alli(f: &fn(uint, t: &T) -> bool) -> bool

Method flat_map

fn flat_map<U>(f: &fn(t: &T) -> ~[U]) -> ~[U]

Method filter_map

fn filter_map<U: Copy>(f: &fn(t: &T) -> Option<U>) -> ~[U]

Interface MutableCopyableVector

Method push_all

fn push_all(rhs: &[const T])

Method grow

fn grow(n: uint, initval: &T)

Method grow_fn

fn grow_fn(n: uint, op: iter::InitOp<T>)

Method grow_set

fn grow_set(index: uint, initval: &T, val: T)

Interface MutableEqVector

Method dedup

fn dedup()

Interface MutableVector

Method push

fn push(t: T)

Method push_all_move

fn push_all_move(rhs: ~[T])

Method pop

fn pop() -> T

Method shift

fn shift() -> T

Method unshift

fn unshift(x: T)

Method insert

fn insert(i: uint, x: T)

Method remove

fn remove(i: uint) -> T

Method swap_remove

fn swap_remove(index: uint) -> T

Method truncate

fn truncate(newlen: uint)

Method retain

fn retain(f: &pure fn(t: &T) -> bool)

Implementation of ConstVector for &[const T]

Extension methods for vectors

Method is_empty

fn is_empty() -> bool

Returns true if a vector contains no elements

Method is_not_empty

fn is_not_empty() -> bool

Returns true if a vector contains some elements

Method len

fn len() -> uint

Returns the length of a vector

Implementation of CopyableVector<T> for &[const T]

Extension methods for vectors

Method head

fn head() -> T

Returns the first element of a vector

Method init

fn init() -> ~[T]

Returns all but the last elemnt of a vector

Method last

fn last() -> T

Returns the last element of a v, failing if the vector is empty.

Method slice

fn slice(start: uint, end: uint) -> ~[T]

Returns a copy of the elements from [start..end) from v.

Method tail

fn tail() -> ~[T]

Returns all but the first element of a vector

Implementation of ImmutableVector<T> for &[T]

Extension methods for vectors

Method view

fn view(start: uint, end: uint) -> &self /[T]

Return a slice that points into another slice.

Method foldr

fn foldr<U: Copy>(z: U, p: &fn(t: &T, u: U) -> U) -> U

Reduce a vector from right to left

Method map

fn map<U>(f: &fn(t: &T) -> U) -> ~[U]

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

Method mapi

fn mapi<U>(f: &fn(uint, t: &T) -> U) -> ~[U]

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

Method map_r

fn map_r<U>(f: &fn(x: &T) -> U) -> ~[U]

Method alli

fn alli(f: &fn(uint, t: &T) -> bool) -> bool

Returns true if the function returns true for all elements.

If the vector is empty, true is returned.

Method flat_map

fn flat_map<U>(f: &fn(t: &T) -> ~[U]) -> ~[U]

Apply a function to each element of a vector and return a concatenation of each result vector

Method filter_map

fn filter_map<U: Copy>(f: &fn(t: &T) -> Option<U>) -> ~[U]

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

If function f returns none then that element is excluded from the resulting vector.

Implementation of ImmutableEqVector<T> for &[T]

Method position

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

Find the first index matching some predicate

Apply function f to each element of v. When function f returns true then an option containing the index is returned. If f matches no elements then none is returned.

Method position_elem

fn position_elem(x: &T) -> Option<uint>

Find the first index containing a matching value

Method rposition

fn rposition(f: &fn(t: &T) -> bool) -> Option<uint>

Find the last index matching some predicate

Apply function f to each element of v in reverse order. When function f returns true then an option containing the index is returned. If f matches no elements then none is returned.

Method rposition_elem

fn rposition_elem(t: &T) -> Option<uint>

Find the last index containing a matching value

Implementation of ImmutableCopyableVector<T> for &[T]

Extension methods for vectors

Method filter

fn filter(f: &fn(t: &T) -> bool) -> ~[T]

Construct a new vector from the elements of a vector for which some predicate holds.

Apply function f to each element of v and return a vector containing only those elements for which f returned true.

Method rfind

fn rfind(f: &fn(t: &T) -> bool) -> Option<T>

Search for the last element that matches a given predicate

Apply function f to each element of v in reverse order. When function f returns true then an option containing the element is returned. If f matches no elements then none is returned.

Implementation of MutableVector<T> for ~[T]

Method push

fn push(t: T)

Method push_all_move

fn push_all_move(rhs: ~[T])

Method pop

fn pop() -> T

Method shift

fn shift() -> T

Method unshift

fn unshift(x: T)

Method insert

fn insert(i: uint, x: T)

Method remove

fn remove(i: uint) -> T

Method swap_remove

fn swap_remove(index: uint) -> T

Method truncate

fn truncate(newlen: uint)

Method retain

fn retain(f: &pure fn(t: &T) -> bool)

Implementation of MutableCopyableVector<T> for ~[T]

Method push_all

fn push_all(rhs: &[const T])

Method grow

fn grow(n: uint, initval: &T)

Method grow_fn

fn grow_fn(n: uint, op: iter::InitOp<T>)

Method grow_set

fn grow_set(index: uint, initval: &T, val: T)

Implementation of MutableEqVector<T> for ~[T]

Method dedup

fn dedup()

Implementation of iter::BaseIter<A> for &[A]

Method each

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

Method size_hint

fn size_hint() -> Option<uint>

Implementation of iter::BaseIter<A> for ~[A]

Method each

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

Method size_hint

fn size_hint() -> Option<uint>

Implementation of iter::BaseIter<A> for @[A]

Method each

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

Method size_hint

fn size_hint() -> Option<uint>

Implementation of iter::ExtendedIter<A> for &[A]

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]

Implementation of iter::ExtendedIter<A> for ~[A]

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]

Implementation of iter::ExtendedIter<A> for @[A]

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]

Implementation of iter::EqIter<A> for &[A]

Method contains

fn contains(x: &A) -> bool

Method count

fn count(x: &A) -> uint

Implementation of iter::EqIter<A> for ~[A]

Method contains

fn contains(x: &A) -> bool

Method count

fn count(x: &A) -> uint

Implementation of iter::EqIter<A> for @[A]

Method contains

fn contains(x: &A) -> bool

Method count

fn count(x: &A) -> uint

Implementation of iter::CopyableIter<A> for &[A]

Method filter_to_vec

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

Method to_vec

fn to_vec() -> ~[A]

Method find

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

Implementation of iter::CopyableIter<A> for ~[A]

Method filter_to_vec

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

Method to_vec

fn to_vec() -> ~[A]

Method find

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

Implementation of iter::CopyableIter<A> for @[A]

Method filter_to_vec

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

Method to_vec

fn to_vec() -> ~[A]

Method find

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

Implementation of iter::CopyableOrderedIter<A> for &[A]

Method min

fn min() -> A

Method max

fn max() -> A

Implementation of iter::CopyableOrderedIter<A> for ~[A]

Method min

fn min() -> A

Method max

fn max() -> A

Implementation of iter::CopyableOrderedIter<A> for @[A]

Method min

fn min() -> A

Method max

fn max() -> A

Implementation of iter::CopyableNonstrictIter<A> for &[A]

Method each_val

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

Implementation of iter::CopyableNonstrictIter<A> for ~[A]

Method each_val

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

Implementation of iter::CopyableNonstrictIter<A> for @[A]

Method each_val

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

Function all

fn all<T>(v: &[T], f: &fn(t: &T) -> bool) -> bool

Return true if a predicate matches all elements

If the vector contains no elements then true is returned.

Function all2

fn all2<T, U>(v0: &[T], v1: &[U], f: &fn(t: &T, u: &U) -> bool) -> bool

Return true if a predicate matches all elements in both vectors.

If the vectors are not the same size then false is returned.

Function alli

fn alli<T>(v: &[T], f: &fn(uint, t: &T) -> bool) -> bool

Return true if a predicate matches all elements

If the vector contains no elements then true is returned.

Function any

fn any<T>(v: &[T], f: &fn(t: &T) -> bool) -> bool

Return true if a predicate matches any elements

If the vector contains no elements then false is returned.

Function any2

fn any2<T, U>(v0: &[T], v1: &[U], f: &fn(a: &T, b: &U) -> bool) -> bool

Return true if a predicate matches any elements in both vectors.

If the vectors contains no elements then false is returned.

Function append

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

Function append_mut

fn append_mut<T: Copy>(lhs: ~[mut T], rhs: &[const T]) -> ~[mut T]

Function append_one

fn append_one<T>(lhs: ~[T], x: T) -> ~[T]

Function as_const_buf

fn as_const_buf<T, U>(s: &[const T], f: &fn(*const T, uint) -> U) -> U

Similar to as_imm_buf but passing a *const T

Function as_imm_buf

fn as_imm_buf<T, U>(s: &[T], f: &fn(*T, uint) -> U) -> U

Work with the buffer of a vector.

Allows for unsafe manipulation of vector contents, which is useful for foreign interop.

Function as_mut_buf

fn as_mut_buf<T, U>(s: &[mut T], f: &fn(*mut T, uint) -> U) -> U

Similar to as_imm_buf but passing a *mut 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 concat

fn concat<T: Copy>(v: &[~[T]]) -> ~[T]

Concatenate a vector of vectors.

Flattens a vector of vectors of T into a single vector of T.

Function connect

fn connect<T: Copy>(v: &[~[T]], sep: &T) -> ~[T]

Concatenate a vector of vectors, placing a given separator between each

Function const_view

fn const_view<T>(v: &r/[const T], start: uint, end: uint) -> &r/[const T]

Return a slice that points into another slice.

Function consume

fn consume<T>(v: ~[T], f: &fn(uint, v: T))

Function consume_mut

fn consume_mut<T>(v: ~[mut T], f: &fn(uint, v: T))

Function contains

fn contains<T: Eq>(v: &[T], x: &T) -> bool

Return true if a vector contains an element with the given value

Function count

fn count<T: Eq>(v: &[T], x: &T) -> uint

Returns the number of elements that are equal to a given value

Function dedup

fn dedup<T: Eq>(v: &mut ~[T])

Remove consecutive repeated elements from a vector; if the vector is sorted, this removes all duplicates.

Function each

fn each<T>(v: &r/[T], f: &fn(&r/T) -> bool)

Iterates over a vector, with option to break

Return true to continue, false to break.

Function each2

fn each2<U, T>(v1: &[U], v2: &[T], f: &fn(u: &U, t: &T) -> bool)

Iterates over two vectors simultaneously

Failure

Both vectors must have the same length

Function each_const

fn each_const<T>(v: &[const T], f: &fn(elem: &const T) -> bool)

Like each(), but for the case where you have a vector that may or may not have mutable contents.

Function each_mut

fn each_mut<T>(v: &[mut T], f: &fn(elem: &mut T) -> bool)

Like each(), but for the case where you have a vector with mutable contents and you would like to mutate the contents as you iterate.

Function each_permutation

fn each_permutation<T: Copy>(v: &[T], put: &fn(ts: &[T]) -> bool)

Iterate over all permutations of vector v.

Permutations are produced in lexicographic order with respect to the order of elements in v (so if v is sorted then the permutations are lexicographically sorted).

The total number of permutations produced is len(v)!. If v contains repeated elements, then some permutations are repeated.

Function eachi

fn eachi<T>(v: &r/[T], f: &fn(uint, v: &r/T) -> bool)

Iterates over a vector's elements and indices

Return true to continue, false to break.

Function eq

fn eq<T: Eq>(a: &[T], b: &[T]) -> bool

Function filter

fn filter<T: Copy>(v: &[T], f: &fn(t: &T) -> bool) -> ~[T]

Construct a new vector from the elements of a vector for which some predicate holds.

Apply function f to each element of v and return a vector containing only those elements for which f returned true.

Function filter_map

fn filter_map<T, U: Copy>(v: &[T], f: &fn(t: &T) -> Option<U>) -> ~[U]

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

If function f returns none then that element is excluded from the resulting vector.

Function find

fn find<T: Copy>(v: &[T], f: &fn(t: &T) -> bool) -> Option<T>

Search for the first element that matches a given predicate

Apply function f to each element of v, starting from the first. When function f returns true then an option containing the element is returned. If f matches no elements then none is returned.

Function find_between

fn find_between<T: Copy>(v: &[T], start: uint, end: uint,
                         f: &fn(t: &T) -> bool) -> Option<T>

Search for the first element that matches a given predicate within a range

Apply function f to each element of v within the range [start, end). When function f returns true then an option containing the element is returned. If f matches no elements then none is returned.

Function flat_map

fn flat_map<T, U>(v: &[T], f: &fn(t: &T) -> ~[U]) -> ~[U]

Apply a function to each element of a vector and return a concatenation of each result vector

Function foldl

fn foldl<T, U>(z: T, v: &[U], p: &fn(t: T, u: &U) -> T) -> T

Reduce a vector from left to right

Function foldr

fn foldr<T, U: Copy>(v: &[T], z: U, p: &fn(t: &T, u: U) -> U) -> U

Reduce a vector from right to left

Function from_buf

fn from_buf<T>(ptr: *T, elts: uint) -> ~[T]

Constructs a vector from an unsafe pointer to a buffer

Arguments

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 from_mut

fn from_mut<T>(v: ~[mut T]) -> ~[T]

Produces an immutable vector from a mut vector.

Function from_slice

fn from_slice<T: Copy>(t: &[T]) -> ~[T]

Creates a new unique vector with the same contents as the slice

Function ge

fn ge<T: Ord>(a: &[T], b: &[T]) -> bool

Function grow

fn grow<T: Copy>(v: &mut ~[T], n: uint, initval: &T)

Expands a vector in place, initializing the new elements to a given value

Arguments

Function grow_fn

fn grow_fn<T>(v: &mut ~[T], n: uint, op: iter::InitOp<T>)

Expands a vector in place, initializing the new elements to the result of a function

Function init_op is called n times with the values [0..n)

Arguments

Function grow_set

fn grow_set<T: Copy>(v: &mut ~[T], index: uint, initval: &T, val: T)

Sets the value of a vector element at a given index, growing the vector as needed

Sets the element at position index to val. If index is past the end of the vector, expands the vector by replicating initval to fill the intervening space.

Function gt

fn gt<T: Ord>(a: &[T], b: &[T]) -> bool

Function head

fn head<T: Copy>(v: &[const T]) -> T

Returns the first element of a vector

Function init

fn init<T: Copy>(v: &[const T]) -> ~[T]

Returns a vector containing all but the last element of a slice

Function insert

fn insert<T>(v: &mut ~[T], i: uint, x: T)

Insert an element at position i within v, shifting all elements after position i one position to the right.

Function is_empty

fn is_empty<T>(v: &[const T]) -> bool

Returns true if a vector contains no elements

Function is_not_empty

fn is_not_empty<T>(v: &[const T]) -> bool

Returns true if a vector contains some elements

Function last

fn last<T: Copy>(v: &[const T]) -> T

Returns the last element of the slice v, failing if the slice is empty.

Function last_opt

fn last_opt<T: Copy>(v: &[const T]) -> Option<T>

Returns Some(x) where x is the last element of the slice v, or none if the vector is empty.

Function le

fn le<T: Ord>(a: &[T], b: &[T]) -> bool

Function len

fn len<T>(v: &[const T]) -> uint

Returns the length of a vector

Function lt

fn lt<T: Ord>(a: &[T], b: &[T]) -> bool

Function map

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

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

Function map2

fn map2<T: Copy, U: Copy, V>(v0: &[T], v1: &[U], f: &fn(t: &T, v: &U) -> V) ->
 ~[V]

Apply a function to each pair of elements and return the results

Function map_consume

fn map_consume<T, U>(v: ~[T], f: &fn(v: T) -> U) -> ~[U]

Function mapi

fn mapi<T, U>(v: &[T], f: &fn(uint, t: &T) -> U) -> ~[U]

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

Function mut_view

fn mut_view<T>(v: &r/[mut T], start: uint, end: uint) -> &r/[mut T]

Return a slice that points into another slice.

Function pop

fn pop<T>(v: &mut ~[T]) -> T

Remove the last element from a vector and return it

Function position

fn position<T>(v: &[T], f: &fn(t: &T) -> bool) -> Option<uint>

Find the first index matching some predicate

Apply function f to each element of v. When function f returns true then an option containing the index is returned. If f matches no elements then none is returned.

Function position_between

fn position_between<T>(v: &[T], start: uint, end: uint, f: &fn(t: &T) -> bool)
 -> Option<uint>

Find the first index matching some predicate within a range

Apply function f to each element of v between the range [start, end). When function f returns true then an option containing the index is returned. If f matches no elements then none is returned.

Function position_elem

fn position_elem<T: Eq>(v: &[T], x: &T) -> Option<uint>

Find the first index containing a matching value

Function push

fn push<T>(v: &mut ~[T], initval: T)

Append an element to a vector

Function push_all

fn push_all<T: Copy>(v: &mut ~[T], rhs: &[const T])

Function push_all_move

fn push_all_move<T>(v: &mut ~[T], rhs: ~[T])

Function push_fast

fn push_fast<T>(v: &mut ~[T], initval: T)

Function push_slow

fn push_slow<T>(v: &mut ~[T], initval: T)

Function remove

fn remove<T>(v: &mut ~[T], i: uint) -> T

Remove and return the element at position i within v, shifting all elements after position i one position to the left.

Function reserve

fn reserve<T>(v: &mut ~[T], n: uint)

Reserves capacity for exactly n elements in the given vector.

If the capacity for v is already equal to or greater than the requested capacity, then no action is taken.

Arguments

Function reserve_at_least

fn reserve_at_least<T>(v: &mut ~[T], n: uint)

Reserves capacity for at least n elements in the given vector.

This function will over-allocate in order to amortize the allocation costs in scenarios where the caller may need to repeatedly reserve additional space.

If the capacity for v is already equal to or greater than the requested capacity, then no action is taken.

Arguments

Function retain

fn retain<T>(v: &mut ~[T], f: &pure fn(t: &T) -> bool)

Like filter(), but in place. Preserves order of v. Linear time.

Function rev_each

fn rev_each<T>(v: &r/[T], blk: &fn(v: &r/T) -> bool)

Iterates over a vector's elements in reverse

Return true to continue, false to break.

Function rev_eachi

fn rev_eachi<T>(v: &r/[T], blk: &fn(i: uint, v: &r/T) -> bool)

Iterates over a vector's elements and indices in reverse

Return true to continue, false to break.

Function reverse

fn reverse<T>(v: &[mut T])

Reverse the order of elements in a vector, in place

Function reversed

fn reversed<T: Copy>(v: &[const T]) -> ~[T]

Returns a vector with the order of elements reversed

Function rfind

fn rfind<T: Copy>(v: &[T], f: &fn(t: &T) -> bool) -> Option<T>

Search for the last element that matches a given predicate

Apply function f to each element of v in reverse order. When function f returns true then an option containing the element is returned. If f matches no elements then none is returned.

Function rfind_between

fn rfind_between<T: Copy>(v: &[T], start: uint, end: uint,
                          f: &fn(t: &T) -> bool) -> Option<T>

Search for the last element that matches a given predicate within a range

Apply function f to each element of v in reverse order within the range [start, end). When function f returns true then an option containing the element is returned. If f matches no elements then none is return.

Function rposition

fn rposition<T>(v: &[T], f: &fn(t: &T) -> bool) -> Option<uint>

Find the last index matching some predicate

Apply function f to each element of v in reverse order. When function f returns true then an option containing the index is returned. If f matches no elements then none is returned.

Function rposition_between

fn rposition_between<T>(v: &[T], start: uint, end: uint,
                        f: &fn(t: &T) -> bool) -> Option<uint>

Find the last index matching some predicate within a range

Apply function f to each element of v in reverse order between the range [start, end). When function f returns true then an option containing the index is returned. If f matches no elements then none is returned.

Function rposition_elem

fn rposition_elem<T: Eq>(v: &[T], x: &T) -> Option<uint>

Find the last index containing a matching value

Function rsplit

fn rsplit<T: Copy>(v: &[T], f: &fn(t: &T) -> bool) -> ~[~[T]]

Reverse split the vector v by applying each element against the predicate f.

Function rsplitn

fn rsplitn<T: Copy>(v: &[T], n: uint, f: &fn(t: &T) -> bool) -> ~[~[T]]

Reverse split the vector v by applying each element against the predicate f up to `n times.

Function same_length

fn same_length<T, U>(xs: &[const T], ys: &[const U]) -> bool

Returns true if two vectors have the same length

Function shift

fn shift<T>(v: &mut ~[T]) -> T

Removes the first element from a vector and return it

Function slice

fn slice<T: Copy>(v: &[const T], start: uint, end: uint) -> ~[T]

Returns a copy of the elements from [start..end) from v.

Function split

fn split<T: Copy>(v: &[T], f: &fn(t: &T) -> bool) -> ~[~[T]]

Split the vector v by applying each element against the predicate f.

Function splitn

fn splitn<T: Copy>(v: &[T], n: uint, f: &fn(t: &T) -> bool) -> ~[~[T]]

Split the vector v by applying each element against the predicate f up to n times.

Function swap

fn swap<T>(v: &[mut T], a: uint, b: uint)

Swaps two elements in a vector

Arguments

Function swap_remove

fn swap_remove<T>(v: &mut ~[T], index: uint) -> T

Remove an element from anywhere in the vector and return it, replacing it with the last element. This does not preserve ordering, but is O(1).

Fails if index >= length.

Function tail

fn tail<T: Copy>(v: &[const T]) -> ~[T]

Returns a vector containing all but the first element of a slice

Function tailn

fn tailn<T: Copy>(v: &[const T], n: uint) -> ~[T]

Returns a vector containing all but the first n \ elements of a slice

Function to_mut

fn to_mut<T>(v: ~[T]) -> ~[mut T]

Produces a mut vector from an immutable vector.

Function truncate

fn truncate<T>(v: &mut ~[T], newlen: uint)

Shorten a vector, dropping excess elements.

Function unshift

fn unshift<T>(v: &mut ~[T], x: T)

Prepend an element to the vector

Function unzip

fn unzip<T, U>(v: ~[(T, U)]) -> (~[T], ~[U])

Convert a vector of pairs into a pair of vectors.

Returns a tuple containing two vectors where the i-th element of the first vector contains the first element of the i-th tuple of the input vector, and the i-th element of the second vector contains the second element of the i-th tuple of the input vector.

Function unzip_slice

fn unzip_slice<T: Copy, U: Copy>(v: &[(T, U)]) -> (~[T], ~[U])

Convert a vector of pairs into a pair of vectors, by reference. As unzip().

Function view

fn view<T>(v: &r/[T], start: uint, end: uint) -> &r/[T]

Return a slice that points into another slice.

Function windowed

fn windowed<TT: Copy>(nn: uint, xx: &[TT]) -> ~[~[TT]]

Function with_capacity

fn with_capacity<T>(capacity: uint) -> ~[T]

Function zip

fn zip<T, U>(v: ~[T], u: ~[U]) -> ~[(T, U)]

Convert two vectors to a vector of pairs.

Returns a vector of tuples, where the i-th tuple contains contains the i-th elements from each of the input vectors.

Function zip_slice

fn zip_slice<T: Copy, U: Copy>(v: &[const T], u: &[const U]) -> ~[(T, U)]

Convert two vectors to a vector of pairs, by reference. As zip().