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>>,
 
impl<'a, V, T> Node<'a, V, T>where
    V: Variant<'a, T, Storage = NodeDataLazyClose<T>>,
sourcepub fn closed_node() -> Self
 
pub fn closed_node() -> Self
Creates a new closed node with no data and no prev and next references.
source§impl<'a, V, T> Node<'a, V, T>where
    V: Variant<'a, T>,
 
impl<'a, V, T> Node<'a, V, T>where
    V: Variant<'a, T>,
sourcepub fn new_free_node(data: T) -> Self
 
pub fn new_free_node(data: T) -> Self
Creates a new free node with the given data without any previous or next references.
sourcepub fn new(data: V::Storage, prev: V::Prev, next: V::Next) -> Self
 
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.
sourcepub fn data(&self) -> Option<&T>
 
pub fn data(&self) -> Option<&T>
Returns a reference to the data stored in the node; None if the node is closed.
sourcepub fn data_mut(&mut self) -> Option<&mut T>
 
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.
sourcepub fn index<Collection>(
    &'a self,
    collection: &Collection
) -> NodeIndex<'a, V, T>where
    Collection: HasCollectionKey<'a, V, T>,
 
pub fn index<Collection>(
    &'a self,
    collection: &Collection
) -> NodeIndex<'a, V, T>where
    Collection: HasCollectionKey<'a, V, T>,
Gets the index of the node.
This index can be:
- stored independent of the self referential collection as a value,
- used to safely access to this node in O(1) time.
sourcepub fn swap_data<'rf, P>(
    &'a self,
    vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>,
    new_value: T
) -> T
 
pub fn swap_data<'rf, P>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>, new_value: T ) -> T
Swaps the data stored in the node with the new_value and returns the old data.
§Panics
Panics if the node is closed.
sourcepub fn set_prev_refs<'rf, P>(
    &'a self,
    vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>,
    prev: V::Prev
)
 
pub fn set_prev_refs<'rf, P>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>, prev: V::Prev )
Updates the previous references of the node as the given prev.
sourcepub fn set_next_refs<'rf, P>(
    &'a self,
    vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>,
    next: V::Next
)
 
pub fn set_next_refs<'rf, P>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>, next: V::Next )
Updates the next references of the node as the given next.
sourcepub fn set_next<'rf, P, Next: Into<V::Next>>(
    &'a self,
    vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>,
    next: Next
)
 
pub fn set_next<'rf, P, Next: Into<V::Next>>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>, next: Next )
Updates the next reference of the node as the given next.
sourcepub fn set_prev<'rf, P, Prev: Into<V::Prev>>(
    &'a self,
    vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>,
    prev: Prev
)
 
pub fn set_prev<'rf, P, Prev: Into<V::Prev>>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>, prev: Prev )
Updates the previous reference of the node as the given prev.
sourcepub fn clear_next<'rf, P>(&'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>)
 
pub fn clear_next<'rf, P>(&'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>)
Clears next references of the node.
sourcepub fn clear_prev<'rf, P>(&'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>)
 
pub fn clear_prev<'rf, P>(&'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>)
Clears previous references of the node.
sourcepub fn close_node_take_data<'rf, P>(
    &'a self,
    vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>
) -> Twhere
    V: Variant<'a, T, Storage = NodeDataLazyClose<T>>,
    P: PinnedVec<Node<'a, V, T>> + 'a,
    SelfRefColMut<'rf, 'a, V, T, P>: Reclaim<V::Prev, V::Next>,
 
pub fn close_node_take_data<'rf, P>(
    &'a self,
    vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>
) -> Twhere
    V: Variant<'a, T, Storage = NodeDataLazyClose<T>>,
    P: PinnedVec<Node<'a, V, T>> + 'a,
    SelfRefColMut<'rf, 'a, V, T, P>: Reclaim<V::Prev, V::Next>,
Closes the lazy node, takes out and returns its data.
§Panics
Panics if the node is already closed; i.e., if self.is_closed().
sourcepub fn close_node_take_data_no_reclaim<'rf, P>(
    &'a self,
    vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>
) -> Twhere
    V: Variant<'a, T, Storage = NodeDataLazyClose<T>>,
    P: PinnedVec<Node<'a, V, T>> + 'a,
    SelfRefColMut<'rf, 'a, V, T, P>: Reclaim<V::Prev, V::Next>,
 
pub fn close_node_take_data_no_reclaim<'rf, P>(
    &'a self,
    vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>
) -> Twhere
    V: Variant<'a, T, Storage = NodeDataLazyClose<T>>,
    P: PinnedVec<Node<'a, V, T>> + 'a,
    SelfRefColMut<'rf, 'a, V, T, P>: Reclaim<V::Prev, V::Next>,
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().
sourcepub fn prev_vec_mut<'rf, P>(
    &'a self,
    vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>
) -> &mut Vec<&'a Node<'a, V, T>>
 
pub fn prev_vec_mut<'rf, P>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P> ) -> &mut Vec<&'a Node<'a, V, T>>
Returns a mutable reference to previous references of the node.
sourcepub fn next_vec_mut<'rf, P>(
    &'a self,
    vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>
) -> &mut Vec<&'a Node<'a, V, T>>
 
pub fn next_vec_mut<'rf, P>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P> ) -> &mut Vec<&'a Node<'a, V, T>>
Returns a mutable reference to next references of the node.
sourcepub 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]
 
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]
Returns a mutable reference to previous references of the node.
sourcepub 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]
 
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]
Returns a mutable reference to next references of the node.