pub struct DoublyLinkedList<T> { /* private fields */ }Expand description
A two-directional linked list, known more commonly as a DoublyLinkedList.
Implementations
Constructs a new, empty, DoublyLinkedList.
Returns the len or the number of Nodes within the DoublyLinkedList.
Example
let list = dl_list![1, 2, 3];
assert_eq!(list.len(), 3);Returns a bool that determines if the list is empty.
Example
let mut list = DoublyLinkedList::<i32>::new();
assert_eq!(list.is_empty(), true);
list.push_back(1);
assert_eq!(list.is_empty(), false);Clears the DoublyLinkedList settings its fields back to their default values.
Example
let mut list = dl_list![1, 2, 3, 4, 5];
list.clear();
assert_eq!(list, DoublyLinkedList::<i32>::new());Returns a reference to the Node at the front of the DoublyLinkedList, also known as the head.
Time complexity is O(1).
Example
let list = dl_list![2, 4, 0];
assert_eq!(list.front(), Some(&2));Returns a reference to the Node at the back of the DoublyLinkedList, also known as the tail.
Time complexity is O(1).
Example
let list = dl_list![2, 4, 0];
assert_eq!(list.back(), Some(&0));Returns a mutable reference to the Node at the front of the DoublyLinkedList, also known as the head.
Time complexity is O(1).
Example
let mut list = dl_list![2, 4, 0];
assert_eq!(list.front_mut(), Some(&mut 2));Returns a mutable reference to the Node at the back of the DoublyLinkedList, also known as the tail.
Time complexity is O(1).
Example
let mut list = dl_list![2, 4, 0];
assert_eq!(list.back_mut(), Some(&mut 0));Pushes or prepends a new Node to the front of the DoublyLinkedList.
Time complexity is O(1).
Example
let mut list = DoublyLinkedList::new();
list.push_front(1);
list.push_front(2);
list.push_front(3);
assert_eq!(list, dl_list![3, 2, 1]);Pushes or appends a new Node to the back of the DoublyLinkedList.
Time complexity is O(1).
Example
let mut list = DoublyLinkedList::new();
list.push_back(1);
list.push_back(2);
list.push_back(3);
assert_eq!(list, dl_list![1, 2, 3]);Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for DoublyLinkedList<T> where
T: RefUnwindSafe,
impl<T> !Send for DoublyLinkedList<T>
impl<T> !Sync for DoublyLinkedList<T>
impl<T> Unpin for DoublyLinkedList<T>
impl<T> UnwindSafe for DoublyLinkedList<T> where
T: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more