Struct collections::dlist::DList
pub struct DList<T> { // some fields omitted }
A doubly-linked list.
Methods
impl<T> DList<T>
fn new() -> DList<T>
Create an empty DList
fn rotate_forward(&mut self)
Move the last element to the front of the list.
If the list is empty, do nothing.
fn rotate_backward(&mut self)
Move the first element to the back of the list.
If the list is empty, do nothing.
fn append(&mut self, other: DList<T>)
Add all elements from other
to the end of the list
O(1)
fn prepend(&mut self, other: DList<T>)
Add all elements from other
to the beginning of the list
O(1)
fn insert_when(&mut self, elt: T, f: |&T, &T| -> bool)
Insert elt
before the first x
in the list where f(x, elt)
is true,
or at the end.
O(N)
fn merge(&mut self, other: DList<T>, f: |&T, &T| -> bool)
Merge DList other
into this DList, using the function f
.
Iterate the both DList with a
from self and b
from other
, and
put a
in the result if f(a, b)
is true, else b
.
O(max(N, M))
fn iter<'a>(&'a self) -> Items<'a, T>
Provide a forward iterator
fn rev_iter<'a>(&'a self) -> Rev<Items<'a, T>>
Provide a reverse iterator
fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T>
Provide a forward iterator with mutable references
fn mut_rev_iter<'a>(&'a mut self) -> Rev<MutItems<'a, T>>
Provide a reverse iterator with mutable references
fn move_iter(self) -> MoveItems<T>
Consume the list into an iterator yielding elements by value
fn move_rev_iter(self) -> Rev<MoveItems<T>>
Consume the list into an iterator yielding elements by value, in reverse
impl<T: Ord> DList<T>
fn insert_ordered(&mut self, elt: T)
Insert elt
sorted in ascending order
O(N)
Trait Implementations
impl<T> Container for DList<T>
impl<T> Mutable for DList<T>
fn clear(&mut self)
Remove all elements from the DList
O(N)
impl<T> Deque<T> for DList<T>
fn front<'a>(&'a self) -> Option<&'a T>
Provide a reference to the front element, or None if the list is empty
fn front_mut<'a>(&'a mut self) -> Option<&'a mut T>
Provide a mutable reference to the front element, or None if the list is empty
fn back<'a>(&'a self) -> Option<&'a T>
Provide a reference to the back element, or None if the list is empty
fn back_mut<'a>(&'a mut self) -> Option<&'a mut T>
Provide a mutable reference to the back element, or None if the list is empty
fn push_front(&mut self, elt: T)
Add an element first in the list
O(1)
fn pop_front(&mut self) -> Option<T>
Remove the first element and return it, or None if the list is empty
O(1)
fn push_back(&mut self, elt: T)
Add an element last in the list
O(1)
fn pop_back(&mut self) -> Option<T>
Remove the last element and return it, or None if the list is empty
O(1)