pub struct Position(/* private fields */);Implementations§
Source§impl Position
impl Position
Sourcepub fn level(self) -> u32
pub fn level(self) -> u32
What level is this node in the tree, 0 if the node is a leaf, 1 if the level is one above a leaf, etc.
pub fn is_leaf(self) -> bool
Sourcepub fn from_level_and_pos(level: u32, pos: u64) -> Self
pub fn from_level_and_pos(level: u32, pos: u64) -> Self
pos count start from 0 on each level
pub fn from_inorder_index(index: u64) -> Self
pub fn to_inorder_index(self) -> u64
pub fn from_postorder_index(index: u64) -> Result<Self>
pub fn to_postorder_index(self) -> u64
Sourcepub fn left_child(self) -> Self
pub fn left_child(self) -> Self
What is the left node of this node? Will overflow if the node is a leaf
Sourcepub fn right_child(self) -> Self
pub fn right_child(self) -> Self
What is the right node of this node? Will overflow if the node is a leaf
Sourcepub fn is_left_child(self) -> bool
pub fn is_left_child(self) -> bool
Whether this position is a left child of its parent. The observation is that, after stripping out all right-most 1 bits, a left child will have a bit pattern of xxx00(11..), while a right child will be represented by xxx10(11..)
pub fn is_right_child(self) -> bool
pub fn from_leaf_index(leaf_index: u64) -> Self
Sourcepub fn sibling(self) -> Self
pub fn sibling(self) -> Self
This method takes in a node position and return its sibling position
The observation is that, after stripping out the right-most common bits, two sibling nodes flip the the next right-most bits with each other. To find out the right-most common bits, first remove all the right-most ones because they are corresponding to level’s indicator. Then remove next zero right after.
Sourcepub fn root_from_leaf_index(leaf_index: u64) -> Self
pub fn root_from_leaf_index(leaf_index: u64) -> Self
This method calculates the index of the smallest root which contains this leaf. Observe that, the root position is composed by a “height” number of ones
For example
0010010(node)
0011111(smearing)
-------
0001111(root)pub fn root_from_leaf_count(leaf_count: LeafCount) -> Self
pub fn root_level_from_leaf_count(leaf_count: LeafCount) -> u32
Sourcepub fn right_most_child(self) -> Self
pub fn right_most_child(self) -> Self
Given a node, find its right most child in its subtree. Right most child is a Position, could be itself, at level 0
Sourcepub fn left_most_child(self) -> Self
pub fn left_most_child(self) -> Self
Given a node, find its left most child in its subtree Left most child is a node, could be itself, at level 0
Source§impl Position
impl Position
pub fn is_freezable(self, leaf_index: u64) -> bool
pub fn is_placeholder(self, leaf_index: u64) -> bool
Sourcepub fn iter_ancestor(self) -> AncestorIterator ⓘ
pub fn iter_ancestor(self) -> AncestorIterator ⓘ
Creates an AncestorIterator using this position.
Sourcepub fn iter_ancestor_sibling(self) -> AncestorSiblingIterator ⓘ
pub fn iter_ancestor_sibling(self) -> AncestorSiblingIterator ⓘ
Creates an AncestorSiblingIterator using this position.
Trait Implementations§
impl Copy for Position
impl Eq for Position
Source§impl Ord for Position
impl Ord for Position
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Position
impl PartialOrd for Position
impl StructuralPartialEq for Position
Auto Trait Implementations§
impl Freeze for Position
impl RefUnwindSafe for Position
impl Send for Position
impl Sync for Position
impl Unpin for Position
impl UnsafeUnpin for Position
impl UnwindSafe for Position
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more