Struct ListSlice

Source
pub struct ListSlice<'a, V, M = MemoryReclaimOnThreshold<2, V, V::Reclaimer>, P = SplitVec<Node<V>, Recursive>>
where V: ListVariant, M: MemoryPolicy<V>, P: PinnedVec<Node<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<V, M> ListSlice<'_, 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<'i, T, M, P> Index<&'i NodeIdx<Doubly<T>>> for ListSlice<'_, Doubly<T>, M, P>
where M: MemoryPolicy<Doubly<T>>, P: PinnedVec<Node<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<'i, T, M, P> Index<&'i NodeIdx<Singly<T>>> for ListSlice<'_, Singly<T>, M, P>
where M: MemoryPolicy<Singly<T>>, P: PinnedVec<Node<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.
Source§

impl<T, M, P> PartialEq for ListSlice<'_, Doubly<T>, M, P>
where T: PartialEq, M: MemoryPolicy<Doubly<T>>, P: PinnedVec<Node<Doubly<T>>>,

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, M, P> PartialEq for ListSlice<'_, Singly<T>, M, P>
where T: PartialEq, M: MemoryPolicy<Singly<T>>, P: PinnedVec<Node<Singly<T>>>,

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, M, P> Eq for ListSlice<'_, Doubly<T>, M, P>
where T: PartialEq, M: MemoryPolicy<Doubly<T>>, P: PinnedVec<Node<Doubly<T>>>,

Source§

impl<T, M, P> Eq for ListSlice<'_, Singly<T>, M, P>
where T: PartialEq, M: MemoryPolicy<Singly<T>>, P: PinnedVec<Node<Singly<T>>>,

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

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

Source§

fn front<'a>(&'a self) -> Option<&'a T>
where M: 'a, P: '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, P: '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<&'a T>
where M: 'a, P: '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<&'a T, NodeIdxError>
where M: 'a, P: '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<&'a T>
where M: 'a, P: '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<&'a T>
where M: 'a, P: '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, P> DoublyIterable<T, M, P> for L
where P: PinnedVec<Node<Doubly<T>>>, L: HasDoublyEnds<T, M, P>, M: MemoryPolicy<Doubly<T>>,

Source§

fn iter_ptr<'a>(&'a self) -> DoublyIterPtr<'a, T, P>
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<'a, T, P>
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, P: 'a,

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

fn pointers<'a>(&'a self) -> impl Iterator<Item = DoublyPtr<T>>
where M: 'a, T: 'a, P: 'a,

Returns an iterator of pointers to the elements of the list. Read more
Source§

fn ring_iter<'a>( &'a self, pivot_idx: &DoublyIdx<T>, ) -> Chain<DoublyIter<'a, T, P>, DoublyIter<'a, T, P>>
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<'a, T, P>
where M: 'a,

Creates a forward iterator: Read more
Source§

fn iter_backward_from<'a>( &'a self, idx: &DoublyIdx<T>, ) -> Rev<DoublyIter<'a, T, P>>
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, P> SinglyEnds<T, M, P> for L
where L: HasSinglyEnds<T, M, P>, M: MemoryPolicy<Singly<T>>, P: PinnedVec<Node<Singly<T>>>,

Source§

fn front<'a>(&'a self) -> Option<&'a T>
where M: 'a, P: '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<&'a T>
where M: 'a, P: '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<&'a T, NodeIdxError>
where M: 'a, P: '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<&'a T>
where M: 'a, P: '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, P> SinglyIterable<T, M, P> for L
where L: HasSinglyEnds<T, M, P>, M: MemoryPolicy<Singly<T>>, P: PinnedVec<Node<Singly<T>>>,

Source§

fn iter_ptr<'a>(&'a self) -> SinglyIterPtr<'a, T, P>
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<'a, T, P>
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, P: 'a,

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

fn pointers<'a>(&'a self) -> impl Iterator<Item = SinglyPtr<T>>
where M: 'a, T: 'a, P: 'a,

Returns an iterator of pointers to the elements of the list. Read more
Source§

fn iter_from<'a>(&'a self, idx: &SinglyIdx<T>) -> SinglyIter<'a, T, P>
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> SoM<T> for T

Source§

fn get_ref(&self) -> &T

Returns a reference to self.
Source§

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

Returns a mutable reference to self.
Source§

impl<T> SoR<T> for T

Source§

fn get_ref(&self) -> &T

Returns a reference to self.
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.