Struct dogged::DVec
[−]
[src]
pub struct DVec<T> { /* fields omitted */ }
A persistent vector of T
elements. Persistent collections
change the trade-off relative to ordinary collections: they are
very cheap to clone, but more expensive to update. Behind the
scenes, DVec
instances that are cloned from one another will
share some part of their representation.
You may be accustomed to persistent APIs in other languages,
where each mutation operation returns a new collection instead of
modifying the collection in place. The DVec
type, in contrast,
behaves roughly like an ordinary vector, except that you can cheaply
clone it. If you want to get a new collection with a given mutation,
but leave the existing collection alone, use clone
:
let mut vec1 = DVec::new(); vec1.push(22); let mut vec2 = vec1.clone(); vec2.push(44); assert_eq!(vec1.len(), 1); assert_eq!(vec2.len(), 2);
Methods
impl<T: Clone + Debug> DVec<T>
[src]
fn new() -> Self
[src]
fn get(&self, index: usize) -> Option<&T>
[src]
fn get_mut(&mut self, index: usize) -> Option<&mut T>
[src]
fn len(&self) -> usize
[src]
fn push(&mut self, element: T)
[src]
Trait Implementations
impl<T: Clone> Clone for DVec<T>
[src]
fn clone(&self) -> DVec<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Debug> Debug for DVec<T>
[src]
impl<T: Ord> Ord for DVec<T>
[src]
fn cmp(&self, __arg_0: &DVec<T>) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.22.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.22.0[src]
Compares and returns the minimum of two values. Read more
impl<T: PartialOrd> PartialOrd for DVec<T>
[src]
fn partial_cmp(&self, __arg_0: &DVec<T>) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &DVec<T>) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &DVec<T>) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &DVec<T>) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &DVec<T>) -> bool
[src]
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 DVec<T>
[src]
impl<T: PartialEq> PartialEq for DVec<T>
[src]
fn eq(&self, __arg_0: &DVec<T>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &DVec<T>) -> bool
[src]
This method tests for !=
.
impl<T: Clone + Debug> Index<usize> for DVec<T>
[src]
type Output = T
The returned type after indexing.
fn index(&self, index: usize) -> &T
[src]
Performs the indexing (container[index]
) operation.