Struct LinkedList

Source
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>

Source

pub fn new() -> LinkedList<T>

Creates a new list

Source

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.

Source

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.

Source

pub fn peek_tail(&self) -> Option<&T>

Returns a reference to the data at the list’s tail, if the list has a tail.

Source

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.

Source

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.

Source

pub fn pop_tail(&mut self) -> Option<T>

Removes and returns the tail node of the list.

Source

pub fn len(&self) -> usize

Returns the length of the list.

Source

pub fn is_empty(&self) -> bool

Returns a Boolean indicating whether the list is empty.

Source

pub fn clear(&mut self)

Clears all elements from the list in O(n) time.

Source

pub fn iter(&self) -> Iter<'_, T>

Returns an iterator of references to data in the list’s nodes as list.iter().

Source

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>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for LinkedList<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T> Drop for LinkedList<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V