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.