Struct fwdlist::List
[−]
[src]
pub struct List<T> { // some fields omitted }
A simply linked list.
Methods
impl<T> List<T>
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>
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>
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>
impl<T> List<T>
fn iter_mut(&mut self) -> ListIterMut<T>
Returns an iterator over the list yielding mutable references.
impl<T> List<T>
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>
Drop the list in O(n).
fn drop(&mut self)
impl<T> Default for List<T>
A default empty list.
impl<T: Debug> Debug for List<T>
A debug formatter.
impl<T: Clone> Clone for List<T>
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>
fn clone_from(&mut self, source: &Self)
impl<T> FromIterator<T> for List<T>
Construct a list from the content of the iterator iter
in O(n).
fn from_iter<I: IntoIterator<Item=T>>(iter: I) -> List<T>
impl<T> Extend<T> for List<T>
Extend the list from the content of iter
in O(n).
fn extend<I>(&mut self, iter: I) where I: IntoIterator<Item=T>
impl<T: Hash> Hash for List<T>
fn hash<H: Hasher>(&self, state: &mut H)
1.3.0fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
impl<A: PartialEq> PartialEq for List<A>
impl<A: Eq> Eq for List<A>
impl<A: PartialOrd> PartialOrd for List<A>
fn partial_cmp(&self, other: &List<A>) -> Option<Ordering>
1.0.0fn lt(&self, other: &Rhs) -> bool
1.0.0fn le(&self, other: &Rhs) -> bool
1.0.0fn gt(&self, other: &Rhs) -> bool
1.0.0fn ge(&self, other: &Rhs) -> bool
impl<A: Ord> Ord for List<A>
impl<T> IntoIterator for List<T>
for v in my_list { v ... }
impl<'a, T> IntoIterator for &'a List<T>
for v in &my_list { *v ... }
impl<'a, T> IntoIterator for &'a mut List<T>
for v in &mut my_list { *v = ... }