pub struct Height(/* private fields */);
Expand description
Abstraction for the height of the tree.
Example:
use dapol::Height;
use std::str::FromStr;
let height = Height::default();
let height = Height::expect_from(8u8);
let height = Height::from_str("8");
Implementations§
source§impl Height
impl Height
sourcepub fn expect_from(int: u8) -> Self
pub fn expect_from(int: u8) -> Self
Create a Height object from int
.
panics if int
is greater than MAX_HEIGHT or less than
MIN_HEIGHT.
Note that if we try to implement the From trait then we have a collision.
sourcepub fn from_y_coord(y_coord: u8) -> Self
pub fn from_y_coord(y_coord: u8) -> Self
Return the height for the given y-coord.
Why the offset? y
starts from 0 but height starts from 1.
See [crate][binary_tree][Coordinate] for more details.
sourcepub fn as_y_coord(&self) -> u8
pub fn as_y_coord(&self) -> u8
Return the y-coord for the given height.
Why the offset? y
starts from 0 but height starts from 1.
See [crate][binary_tree][Coordinate] for more details.
sourcepub fn max_bottom_layer_nodes(&self) -> u64
pub fn max_bottom_layer_nodes(&self) -> u64
The maximum number of leaf nodes on the bottom layer of the binary tree.
$$\text{max} = 2^{\text{height}-1}$$
Trait Implementations§
source§impl<'de> Deserialize<'de> for Height
impl<'de> Deserialize<'de> for Height
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq for Height
impl PartialEq for Height
source§impl PartialOrd for Height
impl PartialOrd for Height
1.0.0 · source§fn 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 moresource§impl TryFrom<u8> for Height
impl TryFrom<u8> for Height
Create a Height object from int
.
Returns an error if int
is greater than MAX_HEIGHT or less than
MIN_HEIGHT.
impl Copy for Height
impl StructuralPartialEq for Height
Auto Trait Implementations§
impl RefUnwindSafe for Height
impl Send for Height
impl Sync for Height
impl Unpin for Height
impl UnwindSafe for Height
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
§impl<T> InitializableFromZeroed for Twhere
T: Default,
impl<T> InitializableFromZeroed for Twhere
T: Default,
§unsafe fn initialize(place: *mut T)
unsafe fn initialize(place: *mut T)
Called to initialize a place to a valid value, after it is set
to all-bits-zero. Read more
§impl<I> IntoResettable<OsStr> for Iwhere
I: Into<OsStr>,
impl<I> IntoResettable<OsStr> for Iwhere
I: Into<OsStr>,
§fn into_resettable(self) -> Resettable<OsStr>
fn into_resettable(self) -> Resettable<OsStr>
Convert to the intended resettable type