[][src]Struct fwdlist::List

pub struct List<T> { /* fields omitted */ }

A simply linked list.

Methods

impl<T> List<T>[src]

pub fn cursor(&mut self) -> Cursor<T>[src]

Return a cursor at the beginning of the list (before the first node).

impl<T> List<T>[src]

Important traits for ListIter<'a, T>
pub fn iter(&self) -> ListIter<T>[src]

Returns an iterator over the list yielding read-only references.

impl<T> List<T>[src]

Important traits for ListIterMut<'a, T>
pub fn iter_mut(&mut self) -> ListIterMut<T>[src]

Returns an iterator over the list yielding mutable references.

impl<T> List<T>[src]

Some accessors to front/back elements.

pub fn front(&self) -> Option<&T>[src]

Returns a reference to the first element in the list.

pub fn front_mut(&mut self) -> Option<&mut T>[src]

Returns a mutable reference to the first element in the list.

pub fn back(&self) -> Option<&T>[src]

Returns a reference to the last element in the list.

pub fn back_mut(&mut self) -> Option<&mut T>[src]

Returns a mutable reference to the last element in the list.

impl<T> List<T>[src]

pub fn new() -> List<T>[src]

A new empty list.

pub fn len(&self) -> usize[src]

The size of the list in O(1).

pub fn is_empty(&self) -> bool[src]

Returns true if list is empty in O(1);

pub fn push_front(&mut self, v: T)[src]

Push a new element at the front of the list in O(1). Cannot fails, only panic!/OOM on memory exhaustion.

pub fn pop_front(&mut self) -> Option<T>[src]

Pop a element from the front of the list in O(1). Returns None if the list is empty.

pub fn push_back(&mut self, v: T)[src]

Push an element at the end of the list in O(n). Cannot fails, only panic!/OOM on memory exhaustion.

pub fn pop_back(&mut self) -> Option<T>[src]

Pop an element from the end of the list in O(n). Returns None if the list is empty.

pub fn clear(&mut self)[src]

Clear the list in O(n).

impl<T> List<T>[src]

Extra operations on the list - Unstable API.

pub fn append(&mut self, other: &mut List<T>)[src]

Moves all elements from other to the end of the list in O(self.len());

pub fn split_off(&mut self, at: usize) -> List<T>[src]

Splits the list into two at the given index in O(at).

  • Returns everything after the given index, including the index.
  • if at == self.len(), returns an empty list in O(1).
  • Panics if at > self.len().

Trait Implementations

impl<T: Clone> Clone for List<T>[src]

Clone a list in O(n).

clone_from() will reuse as many nodes from self as possible to avoid reallocation.

impl<A: PartialEq> PartialEq<List<A>> for List<A>[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl<A: PartialOrd> PartialOrd<List<A>> for List<A>[src]

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<A: Ord> Ord for List<A>[src]

fn max(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Returns max if self is greater than max, and min if self is less than min. Otherwise this will return self. Panics if min > max. Read more

impl<A: Eq> Eq for List<A>[src]

impl<T> IntoIterator for List<T>[src]

for v in my_list { v ... }

type Item = T

The type of the elements being iterated over.

type IntoIter = ListIntoIter<Self::Item>

Which kind of iterator are we turning this into?

impl<'a, T> IntoIterator for &'a List<T>[src]

for v in &my_list { *v ... }

type Item = &'a T

The type of the elements being iterated over.

type IntoIter = ListIter<'a, T>

Which kind of iterator are we turning this into?

impl<'a, T> IntoIterator for &'a mut List<T>[src]

for v in &mut my_list { *v = ... }

type Item = &'a mut T

The type of the elements being iterated over.

type IntoIter = ListIterMut<'a, T>

Which kind of iterator are we turning this into?

impl<T> Drop for List<T>[src]

Drop the list in O(n).

impl<T> Default for List<T>[src]

A default empty list.

impl<T> Extend<T> for List<T>[src]

Extend the list from the content of iter in O(n).

impl<T: Hash> Hash for List<T>[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl<T> FromIterator<T> for List<T>[src]

Construct a list from the content of the iterator iter in O(n).

impl<T: Debug> Debug for List<T>[src]

A debug formatter.

Auto Trait Implementations

impl<T> Send for List<T> where
    T: Send

impl<T> Sync for List<T> where
    T: Sync

Blanket Implementations

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]