pub struct RefsArrayLeftMost<const N: usize, V>where
V: Variant,{ /* private fields */ }
Expand description
A constant number of left-aligned references.
It differs from RefsArray
due to its additional requirement that:
- all Some references are to the left of all None references.
Implementations§
Source§impl<const N: usize, V: Variant> RefsArrayLeftMost<N, V>
impl<const N: usize, V: Variant> RefsArrayLeftMost<N, V>
Sourcepub fn get(&self, ref_idx: usize) -> Option<&NodePtr<V>>
pub fn get(&self, ref_idx: usize) -> Option<&NodePtr<V>>
Returns a reference to the node pointer at the ref_idx
position of the references array.
Sourcepub fn as_slice(&self) -> &[Option<NodePtr<V>>]
pub fn as_slice(&self) -> &[Option<NodePtr<V>>]
Returns the optional node pointers as a slice such that:
- length of the slice is equal to
self.len()
, - all elements of the slice are of
Some
variant, and hence, - can be safely unwrapped to access the node pointer.
Sourcepub fn iter(&self) -> ArrayLeftMostPtrIter<'_, V> ⓘ
pub fn iter(&self) -> ArrayLeftMostPtrIter<'_, V> ⓘ
Creates an iterator over node pointers of the references collection.
Sourcepub fn iter_mut(&mut self) -> ArrayLeftMostPtrIterMut<'_, V> ⓘ
pub fn iter_mut(&mut self) -> ArrayLeftMostPtrIterMut<'_, V> ⓘ
Creates a mutable iterator over node pointers of the references collection.
Sourcepub fn has_room(&self) -> bool
pub fn has_room(&self) -> bool
Returns whether or not the collection has room for another reference.
Sourcepub fn push(&mut self, node_ptr: NodePtr<V>)
pub fn push(&mut self, node_ptr: NodePtr<V>)
Pushes the node references to the end of the references collection.
§Panics
Panics if the array already has N
references; i.e., when self.has_room()
is false.
Sourcepub fn insert(&mut self, position: usize, node_ptr: NodePtr<V>)
pub fn insert(&mut self, position: usize, node_ptr: NodePtr<V>)
Inserts the reference with the given node_ptr
to the given position
of the references collection.
Sourcepub fn push_before(
&mut self,
pivot_ptr: &NodePtr<V>,
node_ptr: NodePtr<V>,
) -> Option<usize>
pub fn push_before( &mut self, pivot_ptr: &NodePtr<V>, node_ptr: NodePtr<V>, ) -> Option<usize>
Inserts the reference with the given node_ptr
just before the given pivot_ptr
the reference if it exists;
and returns the position that the new reference is inserted to.
Does nothing leaving the children unchanged if the pivot_ptr
reference does not exists, and returns None.
Sourcepub fn push_after(
&mut self,
pivot_ptr: &NodePtr<V>,
node_ptr: NodePtr<V>,
) -> Option<usize>
pub fn push_after( &mut self, pivot_ptr: &NodePtr<V>, node_ptr: NodePtr<V>, ) -> Option<usize>
Inserts the reference with the given node_ptr
just after the given pivot_ptr
the reference if it exists;
and returns the position that the new reference is inserted to.
Does nothing leaving the children unchanged if the pivot_ptr
reference does not exists, and returns None.