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 elementprev: V::Prev
: references to the previous nodes in the collectionnext: 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>>,
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 swap_data<'rf, P>(
&'a self,
vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>,
new_value: T
) -> Twhere
P: PinnedVec<Node<'a, V, T>>,
pub fn swap_data<'rf, P>(
&'a self,
vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>,
new_value: T
) -> Twhere
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.
sourcepub 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>>,
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
.
sourcepub 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>>,
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
.
sourcepub 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>>,
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
.
sourcepub 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>>,
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
.
sourcepub fn clear_next<'rf, P>(&'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>)where
P: PinnedVec<Node<'a, V, T>>,
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.
sourcepub fn clear_prev<'rf, P>(&'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>)where
P: PinnedVec<Node<'a, V, T>>,
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.
sourcepub fn close_node_take_data<'rf, P>(
&'a self,
vec_mut: &SelfRefColMut<'rf, 'a, V, T, P>
) -> T
pub fn close_node_take_data<'rf, P>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P> ) -> T
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>
) -> T
pub fn close_node_take_data_no_reclaim<'rf, P>( &'a self, vec_mut: &SelfRefColMut<'rf, 'a, V, T, P> ) -> T
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.