Struct linked_list::LinkedList [] [src]

pub struct LinkedList<T> {
    // some fields omitted
}

An experimental rewrite of LinkedList to provide a more cursor-oriented API.

Methods

impl<T> LinkedList<T>

fn new() -> Self

Returns an empty LinkedList.

fn push_back(&mut self, elem: T)

Appends the given element to the back of the list.

fn push_front(&mut self, elem: T)

Appends the given element to the front of the list.

fn pop_back(&mut self) -> Option<T>

Removes the element at the back of the list and returns it.

Returns None if the list was empty.

fn pop_front(&mut self) -> Option<T>

Removes the element at the front of the list and returns it.

Returns None if the list was empty.

fn front(&self) -> Option<&T>

Returns a reference to the element at the front of the list.

Returns None if the list is empty.

fn back(&self) -> Option<&T>

Returns a reference to the element at the back of the list.

Returns None if the list is empty.

fn front_mut(&mut self) -> Option<&mut T>

Returns a mutable reference to the element at the front of the list.

Returns None if the list is empty.

fn back_mut(&mut self) -> Option<&mut T>

Returns a mutable reference to the element at the back of the list.

Returns None if the list is empty.

fn insert(&mut self, index: usize, elem: T)

Inserts the given element into the list at the given index.

Panics

Panics if the index is greater than the length of the list.

fn remove(&mut self, index: usize) -> Option<T>

Removes the element at the given index and returns it.

Returns None if the index is greater than or equal to the length of the list.

fn split_at(&mut self, index: usize) -> Self

Splits the list into two lists at the given index. Returns the right side of the split. Returns an empty list if index is out of bounds.

This method is deprecated in favor of split_off and will be removed in a future release.

fn split_off(&mut self, index: usize) -> Self

Splits the list in two at the given index.

After this method returns, self contains the elements that previously lay in the range [0, index), and the returned list contains the elements that previously lay in the range [index, len).

Panics

Panics if the given index is greater than the length of the list.

fn append(&mut self, other: &mut Self)

Appends the given list to the end of this one. The old list will be empty afterwards.

fn splice(&mut self, index: usize, other: &mut Self)

Inserts the given list at the given index. The old list will be empty afterwards.

fn len(&self) -> usize

Returns the number of elements in the list.

fn is_empty(&self) -> bool

Checks if the list is empty.

fn clear(&mut self)

Removes all elements from the list.

fn cursor(&mut self) -> Cursor<T>

Returns a cursor over the list.

fn iter(&self) -> Iter<T>

Returns a forward iterator that yields references to the list's elements.

fn iter_mut(&mut self) -> IterMut<T>

Returns a forward iterator that yields mutable references to the list's elements.

Trait Implementations

impl<T> Drop for LinkedList<T>

fn drop(&mut self)

impl<T> Default for LinkedList<T>

fn default() -> Self

impl<T> FromIterator<T> for LinkedList<T>

fn from_iter<I: IntoIterator<Item=T>>(iter: I) -> Self

impl<T> Extend<T> for LinkedList<T>

fn extend<I: IntoIterator<Item=T>>(&mut self, iter: I)

impl<'a, T: 'a + Copy> Extend<&'a T> for LinkedList<T>

fn extend<I: IntoIterator<Item=&'a T>>(&mut self, iter: I)

impl<T: PartialEq> PartialEq for LinkedList<T>

fn eq(&self, other: &Self) -> bool

fn ne(&self, other: &Rhs) -> bool

impl<T: Eq> Eq for LinkedList<T>

impl<T: PartialOrd> PartialOrd for LinkedList<T>

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

fn lt(&self, other: &Rhs) -> bool

fn le(&self, other: &Rhs) -> bool

fn gt(&self, other: &Rhs) -> bool

fn ge(&self, other: &Rhs) -> bool

impl<T: Ord> Ord for LinkedList<T>

fn cmp(&self, other: &Self) -> Ordering

impl<T: Debug> Debug for LinkedList<T>

fn fmt(&self, f: &mut Formatter) -> Result

impl<T: Hash> Hash for LinkedList<T>

fn hash<H: Hasher>(&self, state: &mut H)

fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher

impl<T: Clone> Clone for LinkedList<T>

fn clone(&self) -> Self

fn clone_from(&mut self, source: &Self)

impl<'a, T> IntoIterator for &'a LinkedList<T>

type Item = &'a T

type IntoIter = Iter<'a, T>

fn into_iter(self) -> Iter<'a, T>

impl<'a, T> IntoIterator for &'a mut LinkedList<T>

type Item = &'a mut T

type IntoIter = IterMut<'a, T>

fn into_iter(self) -> IterMut<'a, T>

impl<T> IntoIterator for LinkedList<T>

type Item = T

type IntoIter = IntoIter<T>

fn into_iter(self) -> IntoIter<T>

impl<T: Send> Send for LinkedList<T>

impl<T: Sync> Sync for LinkedList<T>