pub struct LinkedList<T> { /* private fields */ }Expand description
§About
All operations run in O(1) time unless otherwise noted. See the module-level documentation for more information.
Implementations§
Source§impl<T> LinkedList<T>
impl<T> LinkedList<T>
Sourcepub fn new() -> LinkedList<T>
pub fn new() -> LinkedList<T>
Creates a new list
Sourcepub fn push_head(&mut self, element: T)
pub fn push_head(&mut self, element: T)
Inserts a node at the head of the list.
Can be used like a push(k) or add(k) operation for a stack.
Sourcepub fn peek_head(&self) -> Option<&T>
pub fn peek_head(&self) -> Option<&T>
Returns a reference to the data at the list’s head, if the list has a head node.
Sourcepub fn peek_tail(&self) -> Option<&T>
pub fn peek_tail(&self) -> Option<&T>
Returns a reference to the data at the list’s tail, if the list has a tail.
Sourcepub fn pop_head(&mut self) -> Option<T>
pub fn pop_head(&mut self) -> Option<T>
Returns an owned value of the head Node’s data.
Use like a pop() or a dequeue() operation for a stack or queue.
Sourcepub fn push_tail(&mut self, element: T)
pub fn push_tail(&mut self, element: T)
Inserts a node at the tail of the list. Use like an enqueue()
operation for a queue.
Sourcepub fn iter(&self) -> Iter<'_, T> ⓘ
pub fn iter(&self) -> Iter<'_, T> ⓘ
Returns an iterator of references to data in the list’s nodes as
list.iter().
Sourcepub fn cursor_mut(&mut self) -> CursorMut<'_, T>
pub fn cursor_mut(&mut self) -> CursorMut<'_, T>
Acts like a constructor for a cursor.
Trait Implementations§
Source§impl<T: Debug> Debug for LinkedList<T>
impl<T: Debug> Debug for LinkedList<T>
Source§impl<T> Default for LinkedList<T>
impl<T> Default for LinkedList<T>
Auto Trait Implementations§
impl<T> Freeze for LinkedList<T>
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§
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