Vectors
UnboxedVecRepr
- The internal 'unboxed' representation of a vectorConstVector
CopyableVector
ImmutableCopyableVector
ImmutableEqVector
ImmutableVector
MutableCopyableVector
MutableEqVector
MutableVector
of ConstVector for &[const T]
- Extension methods for vectorsof CopyableVector<T> for &[const T]
- Extension methods for vectorsof ImmutableVector<T> for &[T]
- Extension methods for vectorsof ImmutableEqVector<T> for &[T]
of ImmutableCopyableVector<T> for &[T]
- Extension methods for vectorsof MutableVector<T> for ~[T]
of MutableCopyableVector<T> for ~[T]
of MutableEqVector<T> for ~[T]
of iter::BaseIter<A> for &[A]
of iter::BaseIter<A> for ~[A]
of iter::BaseIter<A> for @[A]
of iter::ExtendedIter<A> for &[A]
of iter::ExtendedIter<A> for ~[A]
of iter::ExtendedIter<A> for @[A]
of iter::EqIter<A> for &[A]
of iter::EqIter<A> for ~[A]
of iter::EqIter<A> for @[A]
of iter::CopyableIter<A> for &[A]
of iter::CopyableIter<A> for ~[A]
of iter::CopyableIter<A> for @[A]
of iter::CopyableOrderedIter<A> for &[A]
of iter::CopyableOrderedIter<A> for ~[A]
of iter::CopyableOrderedIter<A> for @[A]
of iter::CopyableNonstrictIter<A> for &[A]
of iter::CopyableNonstrictIter<A> for ~[A]
of iter::CopyableNonstrictIter<A> for @[A]
all
- Return true if a predicate matches all elementsall2
- Return true if a predicate matches all elements in both vectors.alli
- Return true if a predicate matches all elementsany
- Return true if a predicate matches any elementsany2
- Return true if a predicate matches any elements in both vectors.append
append_mut
append_one
as_const_buf
- Similar to as_imm_buf
but passing a *const T
as_imm_buf
- Work with the buffer of a vector.as_mut_buf
- Similar to as_imm_buf
but passing a *mut T
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 reallocatingconcat
- Concatenate a vector of vectors.connect
- Concatenate a vector of vectors, placing a given separator between eachconst_view
- Return a slice that points into another slice.consume
consume_mut
contains
- Return true if a vector contains an element with the given valuecount
- Returns the number of elements that are equal to a given valuededup
- Remove consecutive repeated elements from a vector; if the vector is sorted, this removes all duplicates.each
- Iterates over a vector, with option to breakeach2
- Iterates over two vectors simultaneouslyeach_const
- Like each()
, but for the case where you have a vector that may or may not have mutable contents.each_mut
each_permutation
- Iterate over all permutations of vector v
.eachi
- Iterates over a vector's elements and indiceseq
filter
- Construct a new vector from the elements of a vector for which some predicate holds.filter_map
- Apply a function to each element of a vector and return the resultsfind
- Search for the first element that matches a given predicatefind_between
- Search for the first element that matches a given predicate within a rangeflat_map
- Apply a function to each element of a vector and return a concatenation of each result vectorfoldl
- Reduce a vector from left to rightfoldr
- Reduce a vector from right to leftfrom_buf
- Constructs a vector from an unsafe pointer to a bufferfrom_elem
- Creates and initializes an immutable vector.from_fn
- Creates and initializes an immutable vector.from_mut
- Produces an immutable vector from a mut vector.from_slice
- Creates a new unique vector with the same contents as the slicege
grow
- Expands a vector in place, initializing the new elements to a given valuegrow_fn
- Expands a vector in place, initializing the new elements to the result of a functiongrow_set
- Sets the value of a vector element at a given index, growing the vector as neededgt
head
- Returns the first element of a vectorinit
- Returns a vector containing all but the last element of a sliceinsert
- Insert an element at position i within v, shifting all elements after position i one position to the right.is_empty
- Returns true if a vector contains no elementsis_not_empty
- Returns true if a vector contains some elementslast
- Returns the last element of the slice v
, failing if the slice is empty.last_opt
- Returns Some(x)
where x
is the last element of the slice v
, or none
if the vector is empty.le
len
- Returns the length of a vectorlt
map
- Apply a function to each element of a vector and return the resultsmap2
- Apply a function to each pair of elements and return the resultsmap_consume
mapi
- Apply a function to each element of a vector and return the resultsmut_view
- Return a slice that points into another slice.pop
- Remove the last element from a vector and return itposition
- Find the first index matching some predicateposition_between
- Find the first index matching some predicate within a rangeposition_elem
- Find the first index containing a matching valuepush
- Append an element to a vectorpush_all
push_all_move
push_fast
push_slow
remove
- Remove and return the element at position i within v, shifting all elements after position i one position to the left.reserve
- Reserves capacity for exactly n
elements in the given vector.reserve_at_least
- Reserves capacity for at least n
elements in the given vector.retain
- Like filter()
, but in placerev_each
- Iterates over a vector's elements in reverserev_eachi
- Iterates over a vector's elements and indices in reversereverse
- Reverse the order of elements in a vector, in placereversed
- Returns a vector with the order of elements reversedrfind
- Search for the last element that matches a given predicaterfind_between
- Search for the last element that matches a given predicate within a rangerposition
- Find the last index matching some predicaterposition_between
- Find the last index matching some predicate within a rangerposition_elem
- Find the last index containing a matching valuersplit
- Reverse split the vector v
by applying each element against the predicate f
.rsplitn
- Reverse split the vector v
by applying each element against the predicate f
up to `n times.same_length
- Returns true if two vectors have the same lengthshift
- Removes the first element from a vector and return itslice
- Returns a copy of the elements from [start
..end
) from v
.split
- Split the vector v
by applying each element against the predicate f
.splitn
- Split the vector v
by applying each element against the predicate f
up to n
times.swap
- Swaps two elements in a vectorswap_remove
- Remove an element from anywhere in the vector and return it, replacing it with the last elementtail
- Returns a vector containing all but the first element of a slicetailn
- Returns a vector containing all but the first n
\ elements of a sliceto_mut
- Produces a mut vector from an immutable vector.truncate
- Shorten a vector, dropping excess elements.unshift
- Prepend an element to the vectorunzip
- Convert a vector of pairs into a pair of vectors.unzip_slice
- Convert a vector of pairs into a pair of vectors, by referenceview
- Return a slice that points into another slice.windowed
with_capacity
zip
- Convert two vectors to a vector of pairs.zip_slice
- Convert two vectors to a vector of pairs, by referencevec::bytes
- Operations on [u8]
vec::raw
- Unsafe operationsvec::rusti
vec::rustrt
UnboxedVecRepr
pub struct UnboxedVecRepr {
mut fill: uint,
mut alloc: uint,
data: u8,
}
The internal 'unboxed' representation of a vector
ConstVector
is_empty
fn is_empty() -> bool
is_not_empty
fn is_not_empty() -> bool
len
fn len() -> uint
CopyableVector
head
fn head() -> T
init
fn init() -> ~[T]
last
fn last() -> T
slice
fn slice(start: uint, end: uint) -> ~[T]
tail
fn tail() -> ~[T]
ImmutableCopyableVector
filter
fn filter(f: &fn(t: &T) -> bool) -> ~[T]
rfind
fn rfind(f: &fn(t: &T) -> bool) -> Option<T>
ImmutableEqVector
position
fn position(f: &fn(t: &T) -> bool) -> Option<uint>
position_elem
fn position_elem(t: &T) -> Option<uint>
rposition
fn rposition(f: &fn(t: &T) -> bool) -> Option<uint>
rposition_elem
fn rposition_elem(t: &T) -> Option<uint>
ImmutableVector
view
fn view(start: uint, end: uint) -> &self /[T]
foldr
fn foldr<U: Copy>(z: U, p: &fn(t: &T, u: U) -> U) -> U
map
fn map<U>(f: &fn(t: &T) -> U) -> ~[U]
mapi
fn mapi<U>(f: &fn(uint, t: &T) -> U) -> ~[U]
map_r
fn map_r<U>(f: &fn(x: &T) -> U) -> ~[U]
alli
fn alli(f: &fn(uint, t: &T) -> bool) -> bool
flat_map
fn flat_map<U>(f: &fn(t: &T) -> ~[U]) -> ~[U]
filter_map
fn filter_map<U: Copy>(f: &fn(t: &T) -> Option<U>) -> ~[U]
MutableCopyableVector
push_all
fn push_all(rhs: &[const T])
grow
fn grow(n: uint, initval: &T)
grow_fn
fn grow_fn(n: uint, op: iter::InitOp<T>)
grow_set
fn grow_set(index: uint, initval: &T, val: T)
MutableEqVector
dedup
fn dedup()
MutableVector
push
fn push(t: T)
push_all_move
fn push_all_move(rhs: ~[T])
pop
fn pop() -> T
shift
fn shift() -> T
unshift
fn unshift(x: T)
insert
fn insert(i: uint, x: T)
remove
fn remove(i: uint) -> T
swap_remove
fn swap_remove(index: uint) -> T
truncate
fn truncate(newlen: uint)
retain
fn retain(f: &pure fn(t: &T) -> bool)
ConstVector
for &[const T]
Extension methods for vectors
is_empty
fn is_empty() -> bool
Returns true if a vector contains no elements
is_not_empty
fn is_not_empty() -> bool
Returns true if a vector contains some elements
len
fn len() -> uint
Returns the length of a vector
CopyableVector<T>
for &[const T]
Extension methods for vectors
head
fn head() -> T
Returns the first element of a vector
init
fn init() -> ~[T]
Returns all but the last elemnt of a vector
last
fn last() -> T
Returns the last element of a v
, failing if the vector is empty.
slice
fn slice(start: uint, end: uint) -> ~[T]
Returns a copy of the elements from [start
..end
) from v
.
tail
fn tail() -> ~[T]
Returns all but the first element of a vector
ImmutableVector<T>
for &[T]
Extension methods for vectors
view
fn view(start: uint, end: uint) -> &self /[T]
Return a slice that points into another slice.
foldr
fn foldr<U: Copy>(z: U, p: &fn(t: &T, u: U) -> U) -> U
Reduce a vector from right to left
map
fn map<U>(f: &fn(t: &T) -> U) -> ~[U]
Apply a function to each element of a vector and return the results
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
map_r
fn map_r<U>(f: &fn(x: &T) -> U) -> ~[U]
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.
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
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.
ImmutableEqVector<T>
for &[T]
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.
position_elem
fn position_elem(x: &T) -> Option<uint>
Find the first index containing a matching value
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.
rposition_elem
fn rposition_elem(t: &T) -> Option<uint>
Find the last index containing a matching value
ImmutableCopyableVector<T>
for &[T]
Extension methods for vectors
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.
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.
MutableVector<T>
for ~[T]
push
fn push(t: T)
push_all_move
fn push_all_move(rhs: ~[T])
pop
fn pop() -> T
shift
fn shift() -> T
unshift
fn unshift(x: T)
insert
fn insert(i: uint, x: T)
remove
fn remove(i: uint) -> T
swap_remove
fn swap_remove(index: uint) -> T
truncate
fn truncate(newlen: uint)
retain
fn retain(f: &pure fn(t: &T) -> bool)
MutableCopyableVector<T>
for ~[T]
push_all
fn push_all(rhs: &[const T])
grow
fn grow(n: uint, initval: &T)
grow_fn
fn grow_fn(n: uint, op: iter::InitOp<T>)
grow_set
fn grow_set(index: uint, initval: &T, val: T)
MutableEqVector<T>
for ~[T]
dedup
fn dedup()
iter::BaseIter<A>
for &[A]
each
fn each(blk: &fn(v: &A) -> bool)
size_hint
fn size_hint() -> Option<uint>
iter::BaseIter<A>
for ~[A]
each
fn each(blk: &fn(v: &A) -> bool)
size_hint
fn size_hint() -> Option<uint>
iter::BaseIter<A>
for @[A]
each
fn each(blk: &fn(v: &A) -> bool)
size_hint
fn size_hint() -> Option<uint>
iter::ExtendedIter<A>
for &[A]
eachi
fn eachi(blk: &fn(uint, v: &A) -> bool)
all
fn all(blk: &fn(&A) -> bool) -> bool
any
fn any(blk: &fn(&A) -> bool) -> bool
foldl
fn foldl<B>(b0: B, blk: &fn(&B, &A) -> B) -> B
position
fn position(f: &fn(&A) -> bool) -> Option<uint>
map_to_vec
fn map_to_vec<B>(op: &fn(&A) -> B) -> ~[B]
flat_map_to_vec
fn flat_map_to_vec<B, IB: BaseIter<B>>(op: &fn(&A) -> IB) -> ~[B]
iter::ExtendedIter<A>
for ~[A]
eachi
fn eachi(blk: &fn(uint, v: &A) -> bool)
all
fn all(blk: &fn(&A) -> bool) -> bool
any
fn any(blk: &fn(&A) -> bool) -> bool
foldl
fn foldl<B>(b0: B, blk: &fn(&B, &A) -> B) -> B
position
fn position(f: &fn(&A) -> bool) -> Option<uint>
map_to_vec
fn map_to_vec<B>(op: &fn(&A) -> B) -> ~[B]
flat_map_to_vec
fn flat_map_to_vec<B, IB: BaseIter<B>>(op: &fn(&A) -> IB) -> ~[B]
iter::ExtendedIter<A>
for @[A]
eachi
fn eachi(blk: &fn(uint, v: &A) -> bool)
all
fn all(blk: &fn(&A) -> bool) -> bool
any
fn any(blk: &fn(&A) -> bool) -> bool
foldl
fn foldl<B>(b0: B, blk: &fn(&B, &A) -> B) -> B
position
fn position(f: &fn(&A) -> bool) -> Option<uint>
map_to_vec
fn map_to_vec<B>(op: &fn(&A) -> B) -> ~[B]
flat_map_to_vec
fn flat_map_to_vec<B, IB: BaseIter<B>>(op: &fn(&A) -> IB) -> ~[B]
iter::EqIter<A>
for &[A]
contains
fn contains(x: &A) -> bool
count
fn count(x: &A) -> uint
iter::EqIter<A>
for ~[A]
contains
fn contains(x: &A) -> bool
count
fn count(x: &A) -> uint
iter::EqIter<A>
for @[A]
contains
fn contains(x: &A) -> bool
count
fn count(x: &A) -> uint
iter::CopyableIter<A>
for &[A]
filter_to_vec
fn filter_to_vec(pred: &fn(&A) -> bool) -> ~[A]
to_vec
fn to_vec() -> ~[A]
find
fn find(f: &fn(&A) -> bool) -> Option<A>
iter::CopyableIter<A>
for ~[A]
filter_to_vec
fn filter_to_vec(pred: &fn(&A) -> bool) -> ~[A]
to_vec
fn to_vec() -> ~[A]
find
fn find(f: &fn(&A) -> bool) -> Option<A>
iter::CopyableIter<A>
for @[A]
filter_to_vec
fn filter_to_vec(pred: &fn(&A) -> bool) -> ~[A]
to_vec
fn to_vec() -> ~[A]
find
fn find(f: &fn(&A) -> bool) -> Option<A>
iter::CopyableOrderedIter<A>
for &[A]
min
fn min() -> A
max
fn max() -> A
iter::CopyableOrderedIter<A>
for ~[A]
min
fn min() -> A
max
fn max() -> A
iter::CopyableOrderedIter<A>
for @[A]
min
fn min() -> A
max
fn max() -> A
iter::CopyableNonstrictIter<A>
for &[A]
each_val
fn each_val(f: &fn(A) -> bool)
iter::CopyableNonstrictIter<A>
for ~[A]
each_val
fn each_val(f: &fn(A) -> bool)
iter::CopyableNonstrictIter<A>
for @[A]
each_val
fn each_val(f: &fn(A) -> bool)
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.
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.
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.
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.
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.
append
fn append<T: Copy>(lhs: ~[T], rhs: &[const T]) -> ~[T]
append_mut
fn append_mut<T: Copy>(lhs: ~[mut T], rhs: &[const T]) -> ~[mut T]
append_one
fn append_one<T>(lhs: ~[T], x: T) -> ~[T]
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
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.
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
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
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.
connect
fn connect<T: Copy>(v: &[~[T]], sep: &T) -> ~[T]
Concatenate a vector of vectors, placing a given separator between each
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.
consume
fn consume<T>(v: ~[T], f: &fn(uint, v: T))
consume_mut
fn consume_mut<T>(v: ~[mut T], f: &fn(uint, v: T))
contains
fn contains<T: Eq>(v: &[T], x: &T) -> bool
Return true if a vector contains an element with the given value
count
fn count<T: Eq>(v: &[T], x: &T) -> uint
Returns the number of elements that are equal to a given value
dedup
fn dedup<T: Eq>(v: &mut ~[T])
Remove consecutive repeated elements from a vector; if the vector is sorted, this removes all duplicates.
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.
each2
fn each2<U, T>(v1: &[U], v2: &[T], f: &fn(u: &U, t: &T) -> bool)
Iterates over two vectors simultaneously
Both vectors must have the same length
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.
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.
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.
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.
eq
fn eq<T: Eq>(a: &[T], b: &[T]) -> bool
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.
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.
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.
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.
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
foldl
fn foldl<T, U>(z: T, v: &[U], p: &fn(t: T, u: &U) -> T) -> T
Reduce a vector from left to right
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
from_buf
fn from_buf<T>(ptr: *T, elts: uint) -> ~[T]
Constructs a vector from an unsafe pointer to a buffer
T
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
.
from_mut
fn from_mut<T>(v: ~[mut T]) -> ~[T]
Produces an immutable vector from a mut vector.
from_slice
fn from_slice<T: Copy>(t: &[T]) -> ~[T]
Creates a new unique vector with the same contents as the slice
ge
fn ge<T: Ord>(a: &[T], b: &[T]) -> bool
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
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
)
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.
gt
fn gt<T: Ord>(a: &[T], b: &[T]) -> bool
head
fn head<T: Copy>(v: &[const T]) -> T
Returns the first element of a vector
init
fn init<T: Copy>(v: &[const T]) -> ~[T]
Returns a vector containing all but the last element of a slice
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.
is_empty
fn is_empty<T>(v: &[const T]) -> bool
Returns true if a vector contains no elements
is_not_empty
fn is_not_empty<T>(v: &[const T]) -> bool
Returns true if a vector contains some elements
last
fn last<T: Copy>(v: &[const T]) -> T
Returns the last element of the slice v
, failing if the slice is empty.
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.
le
fn le<T: Ord>(a: &[T], b: &[T]) -> bool
len
fn len<T>(v: &[const T]) -> uint
Returns the length of a vector
lt
fn lt<T: Ord>(a: &[T], b: &[T]) -> bool
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
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
map_consume
fn map_consume<T, U>(v: ~[T], f: &fn(v: T) -> U) -> ~[U]
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
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.
pop
fn pop<T>(v: &mut ~[T]) -> T
Remove the last element from a vector and return it
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.
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.
position_elem
fn position_elem<T: Eq>(v: &[T], x: &T) -> Option<uint>
Find the first index containing a matching value
push
fn push<T>(v: &mut ~[T], initval: T)
Append an element to a vector
push_all
fn push_all<T: Copy>(v: &mut ~[T], rhs: &[const T])
push_all_move
fn push_all_move<T>(v: &mut ~[T], rhs: ~[T])
push_fast
fn push_fast<T>(v: &mut ~[T], initval: T)
push_slow
fn push_slow<T>(v: &mut ~[T], initval: T)
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.
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.
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.
retain
fn retain<T>(v: &mut ~[T], f: &pure fn(t: &T) -> bool)
Like filter()
, but in place. Preserves order of v
. Linear time.
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.
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.
reverse
fn reverse<T>(v: &[mut T])
Reverse the order of elements in a vector, in place
reversed
fn reversed<T: Copy>(v: &[const T]) -> ~[T]
Returns a vector with the order of elements reversed
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.
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.
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.
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.
rposition_elem
fn rposition_elem<T: Eq>(v: &[T], x: &T) -> Option<uint>
Find the last index containing a matching value
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
.
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.
same_length
fn same_length<T, U>(xs: &[const T], ys: &[const U]) -> bool
Returns true if two vectors have the same length
shift
fn shift<T>(v: &mut ~[T]) -> T
Removes the first element from a vector and return it
slice
fn slice<T: Copy>(v: &[const T], start: uint, end: uint) -> ~[T]
Returns a copy of the elements from [start
..end
) from v
.
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
.
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.
swap
fn swap<T>(v: &[mut T], a: uint, b: uint)
Swaps two elements in a vector
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.
tail
fn tail<T: Copy>(v: &[const T]) -> ~[T]
Returns a vector containing all but the first element of a slice
tailn
fn tailn<T: Copy>(v: &[const T], n: uint) -> ~[T]
Returns a vector containing all but the first n
\ elements of a slice
to_mut
fn to_mut<T>(v: ~[T]) -> ~[mut T]
Produces a mut vector from an immutable vector.
truncate
fn truncate<T>(v: &mut ~[T], newlen: uint)
Shorten a vector, dropping excess elements.
unshift
fn unshift<T>(v: &mut ~[T], x: T)
Prepend an element to the vector
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.
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().
view
fn view<T>(v: &r/[T], start: uint, end: uint) -> &r/[T]
Return a slice that points into another slice.
windowed
fn windowed<TT: Copy>(nn: uint, xx: &[TT]) -> ~[~[TT]]
with_capacity
fn with_capacity<T>(capacity: uint) -> ~[T]
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.
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().