Struct orx_linked_list::ListSlice

source ·
pub struct ListSlice<'a, V, M = MemoryReclaimOnThreshold<2, V, V::Reclaimer>>
where V: ListVariant, M: MemoryPolicy<V>,
{ /* private fields */ }
Expand description

A slice of a linked list.

Note that a list slice itself behaves pretty much like a linked list. However, it does not own the data, but provides a view on it, just as a slice of a vec.

Implementations§

source§

impl<'a, V, M> ListSlice<'a, V, M>
where V: ListVariant, M: MemoryPolicy<V>,

source

pub fn is_empty(&self) -> bool

Returns the number of elements in the list.

§Examples
use orx_linked_list::*;

let mut list = SinglyList::new();

assert!(list.is_empty());

list.push_front('a');
assert!(!list.is_empty());

_ = list.pop_front();
assert!(list.is_empty());

Trait Implementations§

source§

impl<'a, 'i, T, M> Index<&'i NodeIdx<Doubly<T>>> for ListSlice<'a, Doubly<T>, M>
where M: MemoryPolicy<Doubly<T>>,

source§

fn index(&self, index: &'i DoublyIdx<T>) -> &Self::Output

Returns the element at the given index.

§Panics

Panics if the index is invalid; i.e.,

  • list.is_valid(index) returns false, equivalently,
  • list.idx_err(index) returns the detail of the error.
source§

type Output = T

The returned type after indexing.
source§

impl<'a, 'i, T, M> Index<&'i NodeIdx<Singly<T>>> for ListSlice<'a, Singly<T>, M>
where M: MemoryPolicy<Singly<T>>,

source§

fn index(&self, index: &'i SinglyIdx<T>) -> &Self::Output

Returns the element at the given index.

§Panics

Panics if the index is invalid; i.e.,

  • list.is_valid(index) returns false, equivalently,
  • list.idx_err(index) returns the detail of the error.
source§

type Output = T

The returned type after indexing.

Auto Trait Implementations§

§

impl<'a, V, M> Freeze for ListSlice<'a, V, M>
where <V as Variant>::Ends: Freeze,

§

impl<'a, V, M> RefUnwindSafe for ListSlice<'a, V, M>

§

impl<'a, V, M> Send for ListSlice<'a, V, M>
where <V as Variant>::Ends: Send + Sync, M: Sync, <V as Variant>::Prev: Sync, <V as Variant>::Next: Sync, <V as Variant>::Item: Sync,

§

impl<'a, V, M> Sync for ListSlice<'a, V, M>
where <V as Variant>::Ends: Sync, M: Sync, <V as Variant>::Prev: Sync, <V as Variant>::Next: Sync, <V as Variant>::Item: Sync,

§

impl<'a, V, M> Unpin for ListSlice<'a, V, M>
where <V as Variant>::Ends: Unpin,

§

impl<'a, V, M> UnwindSafe for ListSlice<'a, V, M>

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<L, T, M> DoublyEnds<T, M> for L
where L: HasDoublyEnds<T, M>, M: MemoryPolicy<Doubly<T>>,

source§

fn front<'a>(&'a self) -> Option<&'a T>
where M: 'a,

O(1) Returns a reference to the front of the list. Read more
source§

fn back<'a>(&'a self) -> Option<&'a T>
where M: 'a,

O(1) Returns a reference to the back of the list. Read more
source§

fn idx_err(&self, idx: &DoublyIdx<T>) -> Option<NodeIdxError>

O(1) Returns a None if the given node idx is valid. Read more
source§

fn is_valid(&self, idx: &DoublyIdx<T>) -> bool

O(1) Returns whether or not the idx is valid for this list; i.e., Read more
source§

fn get<'a>(&'a self, idx: &DoublyIdx<T>) -> Option<&T>
where M: 'a,

O(1) Returns a reference to the node with the given idx in constant time. Read more
source§

fn try_get<'a>(&'a self, idx: &DoublyIdx<T>) -> Result<&T, NodeIdxError>
where M: 'a,

O(1) Returns a reference to the node with the given idx in constant time. Read more
source§

fn next_idx_of(&self, idx: &DoublyIdx<T>) -> Option<DoublyIdx<T>>

O(1) Returns the index of the element succeeding the one with the given idx. Returns None if the element at idx is the back. Read more
source§

fn next_of<'a>(&'a self, idx: &DoublyIdx<T>) -> Option<&T>
where M: 'a,

O(1) Returns the element succeeding the one with the given idx. Returns None if the element at idx is the back. Read more
source§

fn prev_idx_of(&self, idx: &DoublyIdx<T>) -> Option<DoublyIdx<T>>

O(1) Returns the index of the element preceding the one with the given idx. Returns None if the element at idx is the front. Read more
source§

fn prev_of<'a>(&'a self, idx: &DoublyIdx<T>) -> Option<&T>
where M: 'a,

O(1) Returns the element preceding the one with the given idx. Returns None if the element at idx is the front. Read more
source§

impl<L, T, M> DoublyIterable<T, M> for L
where L: HasDoublyEnds<T, M>, M: MemoryPolicy<Doubly<T>>,

source§

fn iter_ptr<'a>(&'a self) -> DoublyIterPtr<'_, T>
where M: 'a,

Returns a double-ended iterator of pointers to the elements of the list from front to back.
source§

fn iter<'a>(&'a self) -> DoublyIter<'_, T>
where M: 'a,

Returns a double-ended iterator to elements of the list: Read more
Creates a forward iterator that yields pairs of successive elements representing links. Read more
source§

fn indices<'a>(&'a self) -> impl Iterator<Item = DoublyIdx<T>>
where M: 'a, T: 'a,

Returns an iterator of indices of elements of the list. Read more
source§

fn ring_iter<'a>( &'a self, pivot_idx: &DoublyIdx<T>, ) -> Chain<DoublyIter<'a, T>, DoublyIter<'a, T>>
where M: 'a,

Creates a forward iterator starting from the pivot_idx and ending at the element before it. Read more
source§

fn iter_from<'a>(&'a self, idx: &DoublyIdx<T>) -> DoublyIter<'_, T>
where M: 'a,

Creates a forward iterator: Read more
source§

fn iter_backward_from<'a>( &'a self, idx: &DoublyIdx<T>, ) -> Rev<DoublyIter<'_, T>>
where M: 'a,

Creates a backward iterator: Read more
Creates a forward iterator that yields pairs of successive elements representing links: Read more
source§

fn eq_to_iter_vals<I>(&self, iter: I) -> bool
where I: IntoIterator<Item = T>, T: PartialEq,

Returns true if the elements of the iterator are equal to those of the list.
source§

fn eq_to_iter_refs<'a, I>(&self, iter: I) -> bool
where I: IntoIterator<Item = &'a T>, T: 'a + PartialEq,

Returns true if the elements of the iterator are equal to those of the list.
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<L, T, M> SinglyEnds<T, M> for L
where L: HasSinglyEnds<T, M>, M: MemoryPolicy<Singly<T>>,

source§

fn front<'a>(&'a self) -> Option<&'a T>
where M: 'a,

O(1) Returns a reference to the front of the list. Read more
source§

fn idx_err(&self, idx: &SinglyIdx<T>) -> Option<NodeIdxError>

O(1) Returns a None if the given node idx is valid. Read more
source§

fn is_valid(&self, idx: &SinglyIdx<T>) -> bool

O(1) Returns whether or not the idx is valid for this list; i.e., Read more
source§

fn get<'a>(&'a self, idx: &SinglyIdx<T>) -> Option<&T>
where M: 'a,

O(1) Returns a reference to the node with the given idx in constant time. Read more
source§

fn try_get<'a>(&'a self, idx: &SinglyIdx<T>) -> Result<&T, NodeIdxError>
where M: 'a,

O(1) Returns a reference to the node with the given idx in constant time. Read more
source§

fn next_idx_of(&self, idx: &SinglyIdx<T>) -> Option<SinglyIdx<T>>

O(1) Returns the index of the element succeeding the one with the given idx. Returns None if the element at idx is the back. Read more
source§

fn next_of<'a>(&'a self, idx: &SinglyIdx<T>) -> Option<&T>
where M: 'a,

O(1) Returns the element succeeding the one with the given idx. Returns None if the element at idx is the back. Read more
source§

impl<L, T, M> SinglyIterable<T, M> for L
where L: HasSinglyEnds<T, M>, M: MemoryPolicy<Singly<T>>,

source§

fn iter_ptr<'a>(&'a self) -> SinglyIterPtr<'_, T>
where M: 'a,

Returns a double-ended iterator of pointers to the elements of the list from front to back.
source§

fn iter<'a>(&'a self) -> SinglyIter<'_, T>
where M: 'a,

Returns a forward iterator to elements of the list from front to back. Read more
source§

fn indices<'a>(&'a self) -> impl Iterator<Item = SinglyIdx<T>>
where M: 'a, T: 'a,

Returns an iterator of indices of elements of the list. Read more
source§

fn iter_from<'a>(&'a self, idx: &SinglyIdx<T>) -> SinglyIter<'_, T>
where M: 'a,

Creates a forward iterator: Read more
source§

fn eq_to_iter_vals<I>(&self, iter: I) -> bool
where I: IntoIterator<Item = T>, T: PartialEq,

Returns true if the elements of the iterator are equal to those of the list.
source§

fn eq_to_iter_refs<'a, I>(&self, iter: I) -> bool
where I: IntoIterator<Item = &'a T>, T: 'a + PartialEq,

Returns true if the elements of the iterator are equal to those of the list.
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.