Struct NodeIdx

Source
pub struct NodeIdx<V>
where V: Variant,
{ /* private fields */ }
Expand description

A node index providing safe and constant time access to elements of the self referential collection.

Implementations§

Source§

impl<V> NodeIdx<V>
where V: Variant,

Source

pub fn new(state: MemoryState, node_ptr: &NodePtr<V>) -> NodeIdx<V>

Creates a new index for the element at the given node_ptr and the collection with the given state.

Source

pub fn is_in_state(&self, state: MemoryState) -> bool

Checks whether or not the state of the index matches that of this index.

Source

pub fn get_ptr(&self, collection_state: MemoryState) -> Option<*mut Node<V>>

Returns the node pointer if the index is in the same state as the collection_state, None otherwise.

Source

pub fn node_ptr(&self) -> NodePtr<V>

Converts the node index into a node pointer.

Source

pub fn is_valid_for<M, P>(&self, collection: &SelfRefCol<V, M, P>) -> bool
where M: MemoryPolicy<V>, P: PinnedVec<Node<V>>,

Returns true only if this index is valid for the given collection.

A node index is valid iff it satisfies the following two conditions:

  • It is created from the given collection.
  • Memory state of the collection has not changed since this index was created.

Trait Implementations§

Source§

impl<V> Clone for NodeIdx<V>
where V: Variant,

Source§

fn clone(&self) -> NodeIdx<V>

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<V> Debug for NodeIdx<V>
where V: Variant,

Source§

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

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

impl<'i, T, M, P> Index<&'i NodeIdx<Doubly<T>>> for List<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<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<Doubly<T>>> for ListSliceMut<'_, 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 List<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<'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<'i, T, M, P> Index<&'i NodeIdx<Singly<T>>> for ListSliceMut<'_, 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<'i, T, M, P> IndexMut<&'i NodeIdx<Doubly<T>>> for List<Doubly<T>, M, P>
where M: MemoryPolicy<Doubly<T>>, P: PinnedVec<Node<Doubly<T>>>,

Source§

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

Returns a mutable reference to 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§

impl<'i, T, M, P> IndexMut<&'i NodeIdx<Doubly<T>>> for ListSliceMut<'_, Doubly<T>, M, P>
where M: MemoryPolicy<Doubly<T>>, P: PinnedVec<Node<Doubly<T>>>,

Source§

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

Returns a mutable reference to 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§

impl<'i, T, M, P> IndexMut<&'i NodeIdx<Singly<T>>> for List<Singly<T>, M, P>
where M: MemoryPolicy<Singly<T>>, P: PinnedVec<Node<Singly<T>>>,

Source§

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

Returns a mutable reference to 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§

impl<'i, T, M, P> IndexMut<&'i NodeIdx<Singly<T>>> for ListSliceMut<'_, Singly<T>, M, P>
where M: MemoryPolicy<Singly<T>>, P: PinnedVec<Node<Singly<T>>>,

Source§

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

Returns a mutable reference to 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§

impl<V> PartialEq for NodeIdx<V>
where V: Variant,

Source§

fn eq(&self, other: &NodeIdx<V>) -> 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<V> Copy for NodeIdx<V>
where V: Copy + Variant,

Source§

impl<V> Eq for NodeIdx<V>
where V: Variant,

Auto Trait Implementations§

§

impl<V> Freeze for NodeIdx<V>

§

impl<V> RefUnwindSafe for NodeIdx<V>

§

impl<V> !Send for NodeIdx<V>

§

impl<V> !Sync for NodeIdx<V>

§

impl<V> Unpin for NodeIdx<V>

§

impl<V> UnwindSafe for NodeIdx<V>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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> ToOwned for T
where T: Clone,

Source§

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