pub struct Position(_);Implementations
sourceimpl 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
sourceimpl 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ⓘNotable traits for AncestorIteratorimpl Iterator for AncestorIterator type Item = Position;
pub fn iter_ancestor(self) -> AncestorIteratorⓘNotable traits for AncestorIteratorimpl Iterator for AncestorIterator type Item = Position;
Creates an AncestorIterator using this position.
sourcepub fn iter_ancestor_sibling(self) -> AncestorSiblingIteratorⓘNotable traits for AncestorSiblingIteratorimpl Iterator for AncestorSiblingIterator type Item = Position;
pub fn iter_ancestor_sibling(self) -> AncestorSiblingIteratorⓘNotable traits for AncestorSiblingIteratorimpl Iterator for AncestorSiblingIterator type Item = Position;
Creates an AncestorSiblingIterator using this position.
Trait Implementations
sourceimpl Ord for Position
impl Ord for Position
sourceimpl PartialOrd<Position> for Position
impl PartialOrd<Position> for Position
sourcefn partial_cmp(&self, other: &Position) -> Option<Ordering>
fn partial_cmp(&self, other: &Position) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
impl 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key and return true if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more