Skip to main content

VebTree

Struct VebTree 

Source
pub struct VebTree<T> { /* private fields */ }
Expand description

A tree stored in van Emde Boas memory layout for cache-oblivious traversal.

Implementations§

Source§

impl<T: Clone> VebTree<T>

Source

pub fn build(input: Vec<TreeNode<T>>) -> Self

Build a VebTree from a list of logical tree nodes.

The first node in input whose id does not appear as any other node’s child is treated as root. If input is empty, returns an empty tree.

Source

pub fn len(&self) -> usize

Number of nodes.

Source

pub fn is_empty(&self) -> bool

Whether the tree is empty.

Source

pub fn get(&self, id: u32) -> Option<&VebEntry<T>>

Look up a node by its original ID. O(1) via hash map.

Source

pub fn get_by_index(&self, idx: u32) -> Option<&VebEntry<T>>

Look up a node by its position in the flat array.

Source

pub fn iter(&self) -> impl Iterator<Item = &VebEntry<T>>

Iterate nodes in vEB order (cache-friendly traversal).

Source

pub fn iter_dfs(&self) -> Vec<&VebEntry<T>>

Iterate nodes in DFS pre-order (logical traversal order).

Source

pub fn root(&self) -> Option<&VebEntry<T>>

Get the root entry (always at position 0 if tree is non-empty).

Source

pub fn as_slice(&self) -> &[VebEntry<T>]

Return the raw flat array slice.

Trait Implementations§

Source§

impl<T: Clone> Clone for VebTree<T>

Source§

fn clone(&self) -> VebTree<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for VebTree<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for VebTree<T>

§

impl<T> RefUnwindSafe for VebTree<T>
where T: RefUnwindSafe,

§

impl<T> Send for VebTree<T>
where T: Send,

§

impl<T> Sync for VebTree<T>
where T: Sync,

§

impl<T> Unpin for VebTree<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for VebTree<T>

§

impl<T> UnwindSafe for VebTree<T>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.