pub struct Position(_);
Implementations§
§impl Position
impl Position
pub 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
pub fn from_level_and_pos(level: u32, pos: u64) -> Position
pub fn from_level_and_pos(level: u32, pos: u64) -> Position
pos count start from 0 on each level
pub fn from_inorder_index(index: u64) -> Position
pub fn to_inorder_index(self) -> u64
pub fn from_postorder_index(index: u64) -> Result<Position, Error>
pub fn to_postorder_index(self) -> u64
pub fn left_child(self) -> Position
pub fn left_child(self) -> Position
What is the left node of this node? Will overflow if the node is a leaf
pub fn right_child(self) -> Position
pub fn right_child(self) -> Position
What is the right node of this node? Will overflow if the node is a leaf
pub 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) -> Position
pub fn sibling(self) -> Position
pub fn sibling(self) -> Position
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.
pub fn root_from_leaf_index(leaf_index: u64) -> Position
pub fn root_from_leaf_index(leaf_index: u64) -> Position
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: u64) -> Position
pub fn root_level_from_leaf_count(leaf_count: u64) -> u32
pub fn right_most_child(self) -> Position
pub fn right_most_child(self) -> Position
Given a node, find its right most child in its subtree. Right most child is a Position, could be itself, at level 0
pub fn left_most_child(self) -> Position
pub fn left_most_child(self) -> Position
Given a node, find its left most child in its subtree Left most child is a node, could be itself, at level 0
§impl Position
impl Position
pub fn is_freezable(self, leaf_index: u64) -> bool
pub fn is_placeholder(self, leaf_index: u64) -> bool
pub fn iter_ancestor(self) -> AncestorIterator ⓘ
pub fn iter_ancestor(self) -> AncestorIterator ⓘ
Creates an AncestorIterator
using this position.
pub fn iter_ancestor_sibling(self) -> AncestorSiblingIterator ⓘ
pub fn iter_ancestor_sibling(self) -> AncestorSiblingIterator ⓘ
Creates an AncestorSiblingIterator
using this position.
Trait Implementations§
§impl Ord for Position
impl Ord for Position
§impl PartialOrd<Position> for Position
impl PartialOrd<Position> for Position
§fn partial_cmp(&self, other: &Position) -> Option<Ordering>
fn partial_cmp(&self, other: &Position) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Position
impl Eq for Position
impl StructuralEq for Position
impl StructuralPartialEq for Position
Auto Trait Implementations§
impl RefUnwindSafe for Position
impl Send for Position
impl Sync for Position
impl Unpin for Position
impl UnwindSafe for Position
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.