Struct linked::LinkedList [−][src]
pub struct LinkedList<T>(_);
Expand description
LinkedList
is an implementation of a singly-linked-list.
Implementations
Determine if this linked list is empty. This is an O(1) computation
Push to the front of the linked list. This is O(1)
let mut ll = LinkedList::new();
ll.push_front(1);
ll.push_front(2);
assert_eq!(ll, LinkedList::from_iter([2, 1]))
Pop from the front of the linked list. This is O(1)
let mut ll = LinkedList::from_iter([1, 2]);
assert_eq!(ll.pop_front(), Some(1));
assert_eq!(ll.pop_front(), Some(2));
assert_eq!(ll.pop_front(), None);
Modify the first value in the linked list. This is O(1)
Modify the last value in the linked list. This is O(n)
Push to the back of the linked list. This is O(n)
let mut ll = LinkedList::new();
ll.push_back(1);
ll.push_back(2);
assert_eq!(ll, LinkedList::from_iter([1, 2]))
Pop from the back of the linked list. This is O(n)
let mut ll = LinkedList::from_iter([1, 2]);
assert_eq!(ll.pop_back(), Some(2));
assert_eq!(ll.pop_back(), Some(1));
assert_eq!(ll.pop_back(), None);
Create an iter over this linked list
let mut ll = LinkedList::from_iter([1, 2, 3]);
assert_eq!(ll.iter().cloned().collect::<Vec<_>>(), vec![1, 2, 3]);
Create a mutable iter over this linked list
let mut ll = LinkedList::from_iter([1, 2, 3]);
ll.iter_mut().for_each(|i| *i *= 2);
assert_eq!(ll, LinkedList::from_iter([2, 4, 6]));
Trait Implementations
Extends a collection with the contents of an iterator. Read more
extend_one
)Extends a collection with exactly one element.
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Creates a value from an iterator. Read more
Auto Trait Implementations
impl<T> RefUnwindSafe for LinkedList<T> where
T: RefUnwindSafe,
impl<T> !Send for LinkedList<T>
impl<T> !Sync for LinkedList<T>
impl<T> Unpin for LinkedList<T>
impl<T> UnwindSafe for LinkedList<T> where
T: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more