pub struct ChildrenNodesOwned<H>(/* private fields */);
Expand description
Owned children of a node.
The maximum size of the children is nibble_ops::NIBBLE_LENGTH
, in order to save memory we
represent only the children until the last missing one. For example, if the children are
[Some(_), None, Some(_), None, None, None, None, None None, None, None, None, None, None, None, None]
we will only store in the vector [Some(_), None, Some(_)]
.
This is useful to save space in the TrieCache when the children are not fully populated.
Before this struct was introduced, the children were stored in a fixed size array of length
nibble_ops::NIBBLE_LENGTH
, to make sure there aren’t any direct accesses to the array that
we’ve missed, wrap it in its own struct, rather than directly use the Vec
.
Implementations§
Source§impl<H> ChildrenNodesOwned<H>
impl<H> ChildrenNodesOwned<H>
Sourcepub fn get(&self, index: usize) -> Option<&NodeHandleOwned<H>>
pub fn get(&self, index: usize) -> Option<&NodeHandleOwned<H>>
Returns the child at the given index.
Sourcepub fn iter(&self) -> impl Iterator<Item = &Option<NodeHandleOwned<H>>>
pub fn iter(&self) -> impl Iterator<Item = &Option<NodeHandleOwned<H>>>
Returns an iterator over all children.
The size of the iterator is always constant goes up to nibble_ops::NIBBLE_LENGTH
, with
None representing the missing children.
Sourcepub fn allocated_len(&self) -> usize
pub fn allocated_len(&self) -> usize
Returns the number of allocated children.
Trait Implementations§
Source§impl<H: Clone> Clone for ChildrenNodesOwned<H>
impl<H: Clone> Clone for ChildrenNodesOwned<H>
Source§fn clone(&self) -> ChildrenNodesOwned<H>
fn clone(&self) -> ChildrenNodesOwned<H>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more