Struct NodeLeaf

Source
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>

Source

pub fn find_offset<F>( &self, offset: usize, stick_end: bool, entry_to_num: F, ) -> Option<(usize, usize)>
where F: Fn(E) -> 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.

Source

pub fn next_leaf(&self) -> Option<NonNull<Self>>

Source

pub fn prev_leaf(&self) -> Option<NonNull<Self>>

Source

pub fn len_entries(&self) -> usize

Source

pub fn as_slice(&self) -> &[E]

Source

pub fn update_parent_count(&mut self, amt: I::Update)

Source

pub fn flush_metric_update(&mut self, marker: &mut I::Update)

Source

pub fn has_root_as_parent(&self) -> bool

Source

pub fn count_items(&self) -> I::Value

Source

pub fn splice_out(&mut self, idx: usize)

Remove a single item from the node

Source

pub fn clear_all(&mut self)

Source

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>

Source

pub fn find(&self, loc: E::Item) -> Option<UnsafeCursor<E, I, IE, LE>>

Trait Implementations§

Source§

impl<E: Debug + ContentTraits, I: Debug + TreeMetrics<E>, const INT_ENTRIES: usize, const LEAF_ENTRIES: usize> Debug for NodeLeaf<E, I, INT_ENTRIES, LEAF_ENTRIES>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.