Struct louds_rs::Louds

source ·
pub struct Louds { /* private fields */ }
Expand description

LOUDS (Level-Order Unary Degree Sequence).

This class can handle tree structure of virtually arbitrary number of nodes.

In fact, N (number of nodes in the tree) is designed to be limited to: N < 2^64 / 2, while each node is represented in 2bits in average.
It should be enough for almost all usecases since a binary data of length of 2^63 consumes 2^20 = 1,048,576 TB (terabytes), which is hard to handle by state-of-the-art computer architecture.

Implementations§

source§

impl Louds

source

pub fn node_num_to_index(&self, node_num: LoudsNodeNum) -> LoudsIndex

§Panics

node_num does not exist in this LOUDS.

source

pub fn index_to_node_num(&self, index: LoudsIndex) -> LoudsNodeNum

§Panics

index does not point to any node in this LOUDS.

source

pub fn child_to_parent(&self, index: LoudsIndex) -> LoudsNodeNum

§Panics
  • index does not point to any node in this LOUDS.
  • index == 0: (node#1 is root and doesn’t have parent)
source

pub fn child_to_ancestors(&self, child: LoudsNodeNum) -> AncestorNodeIter<'_>

Return an iterator to the child and its ancestors’ node numbers.

source

pub fn parent_to_children(&self, node_num: LoudsNodeNum) -> Vec<LoudsIndex>

§Panics

node_num does not exist in this LOUDS.

source

pub fn parent_to_children_indices( &self, node_num: LoudsNodeNum ) -> ChildIndexIter<'_>

§Panics

node_num does not exist in this LOUDS.

source

pub fn parent_to_children_nodes( &self, node_num: LoudsNodeNum ) -> ChildNodeIter<'_>

§Panics

node_num does not exist in this LOUDS.

Trait Implementations§

source§

impl Clone for Louds

source§

fn clone(&self) -> Louds

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Louds

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<&[bool]> for Louds

source§

fn from(bits: &[bool]) -> Self

Prepares for building Louds from LBS (LOUDS Bit vector).

It takes O(log bits) time for validation.

§Panics

Same as Louds::from::<&str>().

source§

impl From<&str> for Louds

source§

fn from(s: &str) -> Self

Prepares for building Louds from LBS (LOUDS Bit vector).

It takes O(log s) time for validation.

§Panics

If s does not represent a LOUDS tree. s must satisfy the following condition as LBS.

  • Starts from “10”
  • In the range of [0, i] for any i (< length of LBS);
    • the number of ‘0’ <= the number of ‘1’ + 1, because:
      • Each node, including virtual root (node num = 0), has one ‘0’.
      • Each node is derived from one ‘1’.
  • In the range of [0, length of LBS);
    • the number of ‘0’ == the number of ‘1’ + 1

Auto Trait Implementations§

§

impl Freeze for Louds

§

impl RefUnwindSafe for Louds

§

impl Send for Louds

§

impl Sync for Louds

§

impl Unpin for Louds

§

impl UnwindSafe for Louds

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.