pub struct SinglyLinkedList<T> { /* private fields */ }
Expand description
A singly-linked list with owned nodes.
This implementation is a simplified version of std::forward_list
in C++.
References:
Implementations§
Source§impl<T> SinglyLinkedList<T>
impl<T> SinglyLinkedList<T>
Sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a new, empty SinglyLinkedList<T>
.
The list will not allocate until elements are pushed onto it.
Sourcepub fn push_front(&mut self, elem: T)
pub fn push_front(&mut self, elem: T)
Sourcepub fn pop_front(&mut self) -> Option<T>
pub fn pop_front(&mut self) -> Option<T>
Removes and returns the first element of the container.
If there are no elements in the container, return None
.
§Complexity
Constant.
Sourcepub fn reverse(&mut self)
pub fn reverse(&mut self)
Reverses the order of the elements in the container.
§Complexity
Linear in the size of the container.
Trait Implementations§
Source§impl<T: Debug> Debug for SinglyLinkedList<T>
impl<T: Debug> Debug for SinglyLinkedList<T>
Source§impl<T> Drop for SinglyLinkedList<T>
impl<T> Drop for SinglyLinkedList<T>
Source§impl<T> IntoIterator for SinglyLinkedList<T>
impl<T> IntoIterator for SinglyLinkedList<T>
Source§impl<T: PartialEq> PartialEq for SinglyLinkedList<T>
impl<T: PartialEq> PartialEq for SinglyLinkedList<T>
Auto Trait Implementations§
impl<T> Freeze for SinglyLinkedList<T>
impl<T> RefUnwindSafe for SinglyLinkedList<T>where
T: RefUnwindSafe,
impl<T> Send for SinglyLinkedList<T>where
T: Send,
impl<T> Sync for SinglyLinkedList<T>where
T: Sync,
impl<T> Unpin for SinglyLinkedList<T>
impl<T> UnwindSafe for SinglyLinkedList<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more