Struct orx_selfref_col::Node

source ·
pub struct Node<'a, V, T>
where V: Variant<'a, T>,
{ /* private fields */ }
Expand description

A node of the self referential collection.

Each node is composed of the following three pieces of data:

  • data: V::Storage: data of the element
  • prev: V::Prev: references to the previous nodes in the collection
  • next: V::Next: references to the previous nodes in the collection

Implementations§

source§

impl<'a, V, T> Node<'a, V, T>
where V: Variant<'a, T, Storage = NodeDataLazyClose<T>>,

source

pub fn closed_node() -> Self

Creates a new closed node with no data and no prev and next references.

source

pub fn is_closed(&self) -> bool

Returns whether the node is closed or not.

source

pub fn is_active(&self) -> bool

Returns whether the node is active or not.

source§

impl<'a, V, T> Node<'a, V, T>
where V: Variant<'a, T>,

source

pub fn new_free_node(data: T) -> Self

Creates a new free node with the given data without any previous or next references.

source

pub fn new(data: V::Storage, prev: V::Prev, next: V::Next) -> Self

Creates a new node with the given data and prev and next references.

source

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

Returns a reference to the data stored in the node; None if the node is closed.

source

pub fn prev(&self) -> &V::Prev

Returns a reference to previous references of the node.

source

pub fn next(&self) -> &V::Next

Returns a reference to next references of the node.

source

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

Returns a mutable reference to the data stored in the node; None if the node is closed.

source

pub fn swap_data<'rf, P>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>, new_value: T ) -> T
where P: PinnedVec<Node<'a, V, T>>,

Swaps the data stored in the node with the new_value and returns the old data.

§Panics

Panics if the node is closed.

source

pub fn set_prev_refs<'rf, P>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>, prev: V::Prev )
where P: PinnedVec<Node<'a, V, T>>,

Updates the previous references of the node as the given prev.

source

pub fn set_next_refs<'rf, P>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>, next: V::Next )
where P: PinnedVec<Node<'a, V, T>>,

Updates the next references of the node as the given next.

source

pub fn set_next<'rf, P, Next: Into<V::Next>>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>, next: Next )
where P: PinnedVec<Node<'a, V, T>>,

Updates the next reference of the node as the given next.

source

pub fn set_prev<'rf, P, Prev: Into<V::Prev>>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>, prev: Prev )
where P: PinnedVec<Node<'a, V, T>>,

Updates the previous reference of the node as the given prev.

source

pub fn clear_next<'rf, P>(&'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>)
where P: PinnedVec<Node<'a, V, T>>,

Clears next references of the node.

source

pub fn clear_prev<'rf, P>(&'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>)
where P: PinnedVec<Node<'a, V, T>>,

Clears previous references of the node.

source

pub fn close_node_take_data<'rf, P>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P> ) -> T
where V: Variant<'a, T, Storage = NodeDataLazyClose<T>>, P: PinnedVec<Node<'a, V, T>> + 'a,

Closes the lazy node, takes out and returns its data.

§Panics

Panics if the node is already closed; i.e., if self.is_closed().

source

pub fn close_node_take_data_no_reclaim<'rf, P>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P> ) -> T
where V: Variant<'a, T, Storage = NodeDataLazyClose<T>>, P: PinnedVec<Node<'a, V, T>> + 'a,

Closes the lazy node, takes out and returns its data. Skips memory reclaim operation regardless of the utilization.

§Panics

Panics if the node is already closed; i.e., if self.is_closed().

source

pub fn prev_vec_mut<'rf, P>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P> ) -> &mut Vec<&'a Node<'a, V, T>>
where V: Variant<'a, T, Prev = NodeRefsVec<'a, V, T>>, P: PinnedVec<Node<'a, V, T>>,

Returns a mutable reference to previous references of the node.

source

pub fn next_vec_mut<'rf, P>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P> ) -> &mut Vec<&'a Node<'a, V, T>>
where V: Variant<'a, T, Next = NodeRefsVec<'a, V, T>>, P: PinnedVec<Node<'a, V, T>>,

Returns a mutable reference to next references of the node.

source

pub fn prev_array_mut<'rf, P, const N: usize>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P> ) -> &mut [Option<&'a Node<'a, V, T>>; N]
where V: Variant<'a, T, Prev = NodeRefsArray<'a, N, V, T>>, P: PinnedVec<Node<'a, V, T>>,

Returns a mutable reference to previous references of the node.

source

pub fn next_array_mut<'rf, P, const N: usize>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P> ) -> &mut [Option<&'a Node<'a, V, T>>; N]
where V: Variant<'a, T, Next = NodeRefsArray<'a, N, V, T>>, P: PinnedVec<Node<'a, V, T>>,

Returns a mutable reference to next references of the node.

Trait Implementations§

source§

impl<'a, V, T> Clone for Node<'a, V, T>
where V: Variant<'a, T>, V::Storage: Clone, T: Clone,

source§

fn clone(&self) -> Self

Clones the node data without the references.

1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<'a, T: Debug, V> Debug for Node<'a, V, T>
where V: Variant<'a, T>, V::Prev: Debug, V::Next: Debug,

source§

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

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

impl<'a, V, T> From<&'a Node<'a, V, T>> for NodeRefSingle<'a, V, T>
where V: Variant<'a, T>,

source§

fn from(single_reference: &'a Node<'a, V, T>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a, V, T> RefUnwindSafe for Node<'a, V, T>
where <V as Variant<'a, T>>::Next: RefUnwindSafe, <V as Variant<'a, T>>::Prev: RefUnwindSafe, <V as Variant<'a, T>>::Storage: RefUnwindSafe,

§

impl<'a, V, T> Send for Node<'a, V, T>
where <V as Variant<'a, T>>::Next: Send, <V as Variant<'a, T>>::Prev: Send, <V as Variant<'a, T>>::Storage: Send,

§

impl<'a, V, T> Sync for Node<'a, V, T>
where <V as Variant<'a, T>>::Next: Sync, <V as Variant<'a, T>>::Prev: Sync, <V as Variant<'a, T>>::Storage: Sync,

§

impl<'a, V, T> Unpin for Node<'a, V, T>
where <V as Variant<'a, T>>::Next: Unpin, <V as Variant<'a, T>>::Prev: Unpin, <V as Variant<'a, T>>::Storage: Unpin,

§

impl<'a, V, T> UnwindSafe for Node<'a, V, T>
where <V as Variant<'a, T>>::Next: UnwindSafe, <V as Variant<'a, T>>::Prev: UnwindSafe, <V as Variant<'a, T>>::Storage: UnwindSafe,

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> 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> ToOwned for T
where 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 T
where 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 T
where 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V