Struct fwdlist::List
[−]
[src]
pub struct List<T> { /* fields omitted */ }
A simply linked list.
Methods
impl<T> List<T>
[src]
fn new() -> List<T>
A new empty list.
fn len(&self) -> usize
The size of the list in O(1).
fn is_empty(&self) -> bool
Returns true if list is empty in O(1);
fn push_front(&mut self, v: T)
Push a new element at the front of the list in O(1). Cannot fails, only panic!/OOM on memory exhaustion.
fn pop_front(&mut self) -> Option<T>
Pop a element from the front of the list in O(1). Returns None if the list is empty.
fn push_back(&mut self, v: T)
Push an element at the end of the list in O(n). Cannot fails, only panic!/OOM on memory exhaustion.
fn pop_back(&mut self) -> Option<T>
Pop an element from the end of the list in O(n). Returns None if the list is empty.
fn clear(&mut self)
Clear the list in O(n).
impl<T> List<T>
[src]
Some accessors to front/back elements.
fn front(&self) -> Option<&T>
Returns a reference to the first element in the list.
fn front_mut(&mut self) -> Option<&mut T>
Returns a mutable reference to the first element in the list.
fn back(&self) -> Option<&T>
Returns a reference to the last element in the list.
fn back_mut(&mut self) -> Option<&mut T>
Returns a mutable reference to the last element in the list.
impl<T> List<T>
[src]
Extra operations on the list - Unstable API.
fn append(&mut self, other: &mut List<T>)
Moves all elements from other
to the end of the list in O(self.len());
fn split_off(&mut self, at: usize) -> List<T>
Splits the list into two at the given index in O(at).
- Returns everything after the given index, including the index.
- if
at == self.len()
, returns an empty list in O(1). - Panics if
at > self.len()
.
impl<T> List<T>
[src]
impl<T> List<T>
[src]
fn iter_mut(&mut self) -> ListIterMut<T>
Returns an iterator over the list yielding mutable references.
impl<T> List<T>
[src]
fn cursor(&mut self) -> Cursor<T>
Return a cursor at the beginning of the list (before the first node).
Trait Implementations
impl<T> Drop for List<T>
[src]
Drop the list in O(n).
impl<T> Default for List<T>
[src]
A default empty list.
impl<T: Debug> Debug for List<T>
[src]
A debug formatter.
impl<T: Clone> Clone for List<T>
[src]
Clone a list in O(n).
clone_from()
will reuse as many nodes from self
as possible to avoid
reallocation.
fn clone(&self) -> List<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T> FromIterator<T> for List<T>
[src]
Construct a list from the content of the iterator iter
in O(n).
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> List<T>
Creates a value from an iterator. Read more
impl<T> Extend<T> for List<T>
[src]
Extend the list from the content of iter
in O(n).
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = T>,
I: IntoIterator<Item = T>,
Extends a collection with the contents of an iterator. Read more
impl<T: Hash> Hash for List<T>
[src]
fn hash<H: Hasher>(&self, state: &mut H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<A: PartialEq> PartialEq for List<A>
[src]
fn eq(&self, other: &List<A>) -> 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<A: Eq> Eq for List<A>
[src]
impl<A: PartialOrd> PartialOrd for List<A>
[src]
fn partial_cmp(&self, other: &List<A>) -> 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<A: Ord> Ord for List<A>
[src]
fn cmp(&self, other: &List<A>) -> Ordering
This method returns an Ordering
between self
and other
. Read more
impl<T> IntoIterator for List<T>
[src]
for v in my_list { v ... }
type Item = T
The type of the elements being iterated over.
type IntoIter = ListIntoIter<Self::Item>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<'a, T> IntoIterator for &'a List<T>
[src]
for v in &my_list { *v ... }
type Item = &'a T
The type of the elements being iterated over.
type IntoIter = ListIter<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<'a, T> IntoIterator for &'a mut List<T>
[src]
for v in &mut my_list { *v = ... }