Struct ds_ext::list::List

source ·
pub struct List<T> { /* private fields */ }
Expand description

A linked list with cardinal indexing and O(log n) get/insert/remove by index

Implementations§

source§

impl<T> List<T>

source

pub fn new() -> Self

Create a new empty List.

source

pub fn with_capacity(capacity: usize) -> Self

Create a new empty List with the given capacity.

source§

impl<T> List<T>

source

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

Borrow the last element in this List, if any.

source

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

Borrow the last element in this List, if any.

source

pub fn clear(&mut self)

Remove all elements from this List.

source

pub fn drain(&mut self) -> Drain<'_, T>

Drain all elements from this List.

source

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

Borrow the first element in this List, if any.

source

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

Borrow the last element in this List, if any.

source

pub fn get(&self, index: usize) -> Option<&T>

Borrow the element at the given index, if any.

source

pub fn get_mut(&mut self, index: usize) -> Option<&mut T>

Borrow the element at the given index mutably, if any.

source

pub fn insert(&mut self, index: usize, value: T)

Insert a new value at the given index.

source

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

Iterate over all elements in this List.

source

pub fn is_empty(&self) -> bool

Return true if this List is empty.

source

pub fn len(&self) -> usize

Return the length of this List.

source

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

Remove and return the last value in this List.

source

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

Remove and return the first value in this List.

source

pub fn push_back(&mut self, value: T)

Append the given value to the back of this List.

source

pub fn push_front(&mut self, value: T)

Append the given value to the front of this List.

source

pub fn range<R: RangeBounds<usize>>(&self, range: R) -> Iter<'_, T>

Iterate over the given range of elements in this List.

source

pub fn remove(&mut self, index: usize) -> Option<T>

Remove and return the value at the given index, if any.

source

pub fn starts_with<'a, I: IntoIterator<Item = &'a T>>( &'a self, other: I ) -> boolwhere T: PartialEq,

Return true if the first elements in this List are equal to those in the given iter.

source

pub fn swap(&mut self, from: usize, to: usize)

Swap the value at from with the value at to.

Trait Implementations§

source§

impl<T: Clone> Clone for List<T>

source§

fn clone(&self) -> List<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for List<T>

source§

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

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

impl<T> Extend<T> for List<T>

source§

fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<T> FromIterator<T> for List<T>

source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
source§

impl<T: GetSize> GetSize for List<T>

source§

fn get_heap_size(&self) -> usize

Determines how many bytes this object occupies inside the heap. Read more
source§

fn get_stack_size() -> usize

Determines how may bytes this object occupies inside the stack. Read more
source§

fn get_size(&self) -> usize

Determines the total size of the object. Read more
source§

impl<'a, T> IntoIterator for &'a List<T>

§

type Item = &'a T

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T> IntoIterator for List<T>

§

type Item = T

The type of the elements being iterated over.
§

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T: PartialEq> PartialEq<List<T>> for List<T>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: PartialEq> PartialEq<Vec<T, Global>> for List<T>

source§

fn eq(&self, other: &Vec<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Eq> Eq for List<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for List<T>where T: RefUnwindSafe,

§

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

§

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

§

impl<T> Unpin for List<T>where T: Unpin,

§

impl<T> UnwindSafe for List<T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.