pub struct InOrderIndex { /* private fields */ }
Expand description
Index of nodes in a perfectly balanced binary tree based on an in-order tree walk.
Implementations§
source§impl InOrderIndex
impl InOrderIndex
sourcepub fn new(idx: NonZeroUsize) -> InOrderIndex
pub fn new(idx: NonZeroUsize) -> InOrderIndex
Returns a new InOrderIndex instantiated from the provided value.
sourcepub fn from_leaf_pos(leaf: usize) -> InOrderIndex
pub fn from_leaf_pos(leaf: usize) -> InOrderIndex
Return a new InOrderIndex instantiated from the specified leaf position.
§Panics:
If leaf
is higher than or equal to usize::MAX / 2
.
sourcepub fn is_leaf(&self) -> bool
pub fn is_leaf(&self) -> bool
True if the index is pointing at a leaf.
Every odd number represents a leaf.
sourcepub fn is_left_child(&self) -> bool
pub fn is_left_child(&self) -> bool
Returns true if this note is a left child of its parent.
sourcepub fn level(&self) -> u32
pub fn level(&self) -> u32
Returns the level of the index.
Starts at level zero for leaves and increases by one for each parent.
sourcepub fn left_child(&self) -> InOrderIndex
pub fn left_child(&self) -> InOrderIndex
sourcepub fn right_child(&self) -> InOrderIndex
pub fn right_child(&self) -> InOrderIndex
sourcepub fn parent(&self) -> InOrderIndex
pub fn parent(&self) -> InOrderIndex
Returns the index of the parent node.
sourcepub fn sibling(&self) -> InOrderIndex
pub fn sibling(&self) -> InOrderIndex
Returns the index of the sibling node.
sourcepub fn inner(&self) -> u64
pub fn inner(&self) -> u64
Returns the inner value of this InOrderIndex.
Trait Implementations§
source§impl Clone for InOrderIndex
impl Clone for InOrderIndex
source§fn clone(&self) -> InOrderIndex
fn clone(&self) -> InOrderIndex
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for InOrderIndex
impl Debug for InOrderIndex
source§impl Deserializable for InOrderIndex
impl Deserializable for InOrderIndex
source§fn read_from<R: ByteReader>(
source: &mut R,
) -> Result<Self, DeserializationError>
fn read_from<R: ByteReader>( source: &mut R, ) -> Result<Self, DeserializationError>
Reads a sequence of bytes from the provided
source
, attempts to deserialize these bytes
into Self
, and returns the result. Read moresource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
source§impl From<InOrderIndex> for u64
impl From<InOrderIndex> for u64
source§fn from(index: InOrderIndex) -> Self
fn from(index: InOrderIndex) -> Self
Converts to this type from the input type.
source§impl Ord for InOrderIndex
impl Ord for InOrderIndex
source§fn cmp(&self, other: &InOrderIndex) -> Ordering
fn cmp(&self, other: &InOrderIndex) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for InOrderIndex
impl PartialEq for InOrderIndex
source§impl PartialOrd for InOrderIndex
impl PartialOrd for InOrderIndex
source§impl Serializable for InOrderIndex
impl Serializable for InOrderIndex
source§fn write_into<W: ByteWriter>(&self, target: &mut W)
fn write_into<W: ByteWriter>(&self, target: &mut W)
Serializes
self
into bytes and writes these bytes into the target
.source§fn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
Returns an estimate of how many bytes are needed to represent self. Read more
impl Copy for InOrderIndex
impl Eq for InOrderIndex
impl StructuralPartialEq for InOrderIndex
Auto Trait Implementations§
impl Freeze for InOrderIndex
impl RefUnwindSafe for InOrderIndex
impl Send for InOrderIndex
impl Sync for InOrderIndex
impl Unpin for InOrderIndex
impl UnwindSafe for InOrderIndex
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)