Struct libreal::vec::Vec
[−]
[src]
pub struct Vec<T> { // some fields omitted }
Growable array
Methods
impl<T> Vec<T>
[src]
fn new() -> Vec<T>
Make a new array.
fn with_capacity(cap: usize) -> Option<Vec<T>>
Make a new array with enough room to hold at least cap
elements.
Failures
Returns None
if allocation fails.
fn length(&self) -> usize
Return number of elements in array.
fn capacity(&self) -> usize
Return number of elements array can hold before reallocation.
fn reserve(&mut self, n_more: usize) -> bool
Make sure the array has enough room for at least n_more
more elements, reallocating if need be.
Failures
Returns false
if allocation fails, true
otherwise.
fn relinquish(&mut self) -> bool
Relinquish memory so capacity = length.
fn insert(&mut self, k: usize, x: T) -> Result<(), T>
Insert element x
at position k
, shifting elements after k
aftward one position to make room.
Failures
Returns Err(x)
if allocation fails.
Panics
Panics if k
is out of bounds.
fn delete(&mut self, k: usize) -> T
Delete element at position k
and return it, shifting elements after k
forward one position to fill the gap.
Panics
Panics if k
is out of bounds.
fn delete_swap_last(&mut self, k: usize) -> T
Delete element at position k
and move the last element into the gap.
Panics
Panics if k
is out of bounds.
fn push(&mut self, x: T) -> Result<(), T>
fn pop(&mut self) -> Option<T>
Pop last element off end of array.
Return None
if array empty.
fn append(&mut self, xs: Self) -> Result<(), Self>
Append xs
to the array.
Failures
Returns Err(xs)
if allocation fails, in which case both self
and xs
are unmodified.
fn split_off(&mut self, k: usize) -> Option<Vec<T>>
Split off and return the segment of the array from k
to the aft end, inclusive.
Failures
Returns None
if allocation fails, in which case self
is unmodified.
Panics
Panics if k
is out of bounds.
fn extend<Ts: IntoIterator<Item=T>>(&mut self, xs: Ts) -> Result<(), Ts::IntoIter>
Add elements of xs
to aft end of array.
Failures
Returns Err
of remainder of xs
if allocation fails.
fn from_iter<Ts: IntoIterator<Item=T>>(xs: Ts) -> Result<Vec<T>, Ts::IntoIter>
Add elements of xs
to aft end of array.
Failures
Returns Err
of remainder of xs
if allocation fails, in which case some elements may have been added to xs
already.
fn truncate(&mut self, len: usize)
Shorten array to len
and drop elements beyond.
Trait Implementations
impl<T: Send> Send for Vec<T>
[src]
impl<T: Sync> Sync for Vec<T>
[src]
impl<T> Drop for Vec<T>
[src]
impl<T> Default for Vec<T>
[src]
impl<T: PartialEq> PartialEq for Vec<T>
[src]
fn eq(&self, other: &Self) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl<T: PartialOrd> PartialOrd for Vec<T>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T: Eq> Eq for Vec<T>
[src]
impl<T: Ord> Ord for Vec<T>
[src]
fn cmp(&self, other: &Self) -> Ordering
This method returns an Ordering
between self
and other
. Read more
impl<T> Index<usize> for Vec<T>
[src]
type Output = T
The returned type after indexing
fn index(&self, k: usize) -> &T
The method for the indexing (Foo[Bar]
) operation
impl<T> IndexMut<usize> for Vec<T>
[src]
fn index_mut(&mut self, k: usize) -> &mut T
The method for the indexing (Foo[Bar]
) operation
impl<T> Index<Range<usize>> for Vec<T>
[src]
type Output = [T]
The returned type after indexing
fn index(&self, k: Range<usize>) -> &[T]
The method for the indexing (Foo[Bar]
) operation
impl<T> IndexMut<Range<usize>> for Vec<T>
[src]
fn index_mut(&mut self, k: Range<usize>) -> &mut [T]
The method for the indexing (Foo[Bar]
) operation
impl<T> Index<RangeTo<usize>> for Vec<T>
[src]
type Output = [T]
The returned type after indexing
fn index(&self, k: RangeTo<usize>) -> &[T]
The method for the indexing (Foo[Bar]
) operation
impl<T> IndexMut<RangeTo<usize>> for Vec<T>
[src]
fn index_mut(&mut self, k: RangeTo<usize>) -> &mut [T]
The method for the indexing (Foo[Bar]
) operation
impl<T> Index<RangeFrom<usize>> for Vec<T>
[src]
type Output = [T]
The returned type after indexing
fn index(&self, k: RangeFrom<usize>) -> &[T]
The method for the indexing (Foo[Bar]
) operation
impl<T> IndexMut<RangeFrom<usize>> for Vec<T>
[src]
fn index_mut(&mut self, k: RangeFrom<usize>) -> &mut [T]
The method for the indexing (Foo[Bar]
) operation
impl<T> Index<RangeFull> for Vec<T>
[src]
type Output = [T]
The returned type after indexing
fn index(&self, _: RangeFull) -> &[T]
The method for the indexing (Foo[Bar]
) operation
impl<T> IndexMut<RangeFull> for Vec<T>
[src]
impl<T> Deref for Vec<T>
[src]
type Target = [T]
The resulting type after dereferencing
fn deref(&self) -> &[T]
The method called to dereference a value
impl<T> DerefMut for Vec<T>
[src]
fn deref_mut(&mut self) -> &mut [T]
The method called to mutably dereference a value
impl<T: Hash> Hash for Vec<T>
[src]
fn hash<H: Hasher>(&self, h: &mut H)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.
impl<T: Debug> Debug for Vec<T>
[src]
impl<T> IntoIterator for Vec<T>
[src]
type Item = T
The type of the elements being iterated over.
type IntoIter = IntoIter<T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> IntoIter<T>
Creates an iterator from a value. Read more
impl<'a, T> IntoIterator for &'a Vec<T>
[src]
type Item = &'a T
The type of the elements being iterated over.
type IntoIter = Iter<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Iter<'a, T>
Creates an iterator from a value. Read more