pub struct NodeLeaf<E: ContentTraits, I: TreeMetrics<E>, const INT_ENTRIES: usize = DEFAULT_IE, const LEAF_ENTRIES: usize = DEFAULT_LE> { /* private fields */ }
Expand description
A leaf node in the B-tree. Except the root, each child stores MAX_CHILDREN/2 - MAX_CHILDREN entries.
The details in a leaf node are private. This is exposed to allow consumers to build custom indexes, allowing for fast cursor creation without needing to iterate through the tree.
See diamond-types for an example of this.
Implementations§
Source§impl<E: ContentTraits, I: TreeMetrics<E>, const IE: usize, const LE: usize> NodeLeaf<E, I, IE, LE>
impl<E: ContentTraits, I: TreeMetrics<E>, const IE: usize, const LE: usize> NodeLeaf<E, I, IE, LE>
Sourcepub fn find_offset<F>(
&self,
offset: usize,
stick_end: bool,
entry_to_num: F,
) -> Option<(usize, usize)>
pub fn find_offset<F>( &self, offset: usize, stick_end: bool, entry_to_num: F, ) -> Option<(usize, usize)>
Find a given text offset within the node.
Returns (index, offset within entry)
TODO: Add a parameter for figuring out the offset at content length, and pass that in from the ContentLength trait.
pub fn next_leaf(&self) -> Option<NonNull<Self>>
pub fn prev_leaf(&self) -> Option<NonNull<Self>>
pub fn len_entries(&self) -> usize
pub fn as_slice(&self) -> &[E]
pub fn update_parent_count(&mut self, amt: I::Update)
pub fn flush_metric_update(&mut self, marker: &mut I::Update)
pub fn has_root_as_parent(&self) -> bool
pub fn count_items(&self) -> I::Value
Sourcepub fn splice_out(&mut self, idx: usize)
pub fn splice_out(&mut self, idx: usize)
Remove a single item from the node
pub fn clear_all(&mut self)
pub fn unsafe_cursor_at_start(&self) -> UnsafeCursor<E, I, IE, LE>
Source§impl<E: ContentTraits + Searchable, I: TreeMetrics<E>, const IE: usize, const LE: usize> NodeLeaf<E, I, IE, LE>
impl<E: ContentTraits + Searchable, I: TreeMetrics<E>, const IE: usize, const LE: usize> NodeLeaf<E, I, IE, LE>
pub fn find(&self, loc: E::Item) -> Option<UnsafeCursor<E, I, IE, LE>>
Trait Implementations§
Auto Trait Implementations§
impl<E, I, const INT_ENTRIES: usize, const LEAF_ENTRIES: usize> Freeze for NodeLeaf<E, I, INT_ENTRIES, LEAF_ENTRIES>where
E: Freeze,
impl<E, I, const INT_ENTRIES: usize, const LEAF_ENTRIES: usize> RefUnwindSafe for NodeLeaf<E, I, INT_ENTRIES, LEAF_ENTRIES>
impl<E, I, const INT_ENTRIES: usize = DEFAULT_IE, const LEAF_ENTRIES: usize = DEFAULT_LE> !Send for NodeLeaf<E, I, INT_ENTRIES, LEAF_ENTRIES>
impl<E, I, const INT_ENTRIES: usize = DEFAULT_IE, const LEAF_ENTRIES: usize = DEFAULT_LE> !Sync for NodeLeaf<E, I, INT_ENTRIES, LEAF_ENTRIES>
impl<E, I, const INT_ENTRIES: usize = DEFAULT_IE, const LEAF_ENTRIES: usize = DEFAULT_LE> !Unpin for NodeLeaf<E, I, INT_ENTRIES, LEAF_ENTRIES>
impl<E, I, const INT_ENTRIES: usize, const LEAF_ENTRIES: usize> UnwindSafe for NodeLeaf<E, I, INT_ENTRIES, LEAF_ENTRIES>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more