louds_rs/
louds.rs

1mod louds_impl;
2
3extern crate fid_rs;
4use fid_rs::Fid;
5
6#[cfg(feature = "serde")]
7use serde::{Deserialize, Serialize};
8
9#[cfg(feature = "mem_dbg")]
10use mem_dbg::{MemDbg, MemSize};
11
12/// LOUDS (Level-Order Unary Degree Sequence).
13///
14/// This class can handle tree structure of virtually **arbitrary number of nodes**.
15///
16/// 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.<br>
17/// 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.
18#[derive(Clone, Debug)]
19#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
20#[cfg_attr(feature = "mem_dbg", derive(MemDbg, MemSize))]
21pub struct Louds {
22    lbs: Fid,
23}
24
25#[derive(PartialEq, Eq, Debug, Clone, Copy)]
26#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
27#[cfg_attr(feature = "mem_dbg", derive(MemDbg, MemSize))]
28#[repr(transparent)]
29/// Node number of [Louds](struct.Louds.html) tree
30pub struct LoudsNodeNum(pub u64);
31
32#[derive(PartialEq, Eq, Debug, Clone, Copy)]
33#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
34#[cfg_attr(feature = "mem_dbg", derive(MemDbg, MemSize))]
35#[repr(transparent)]
36/// Index of [Louds](struct.Louds.html) tree
37pub struct LoudsIndex(pub u64);
38
39/// An index iterator
40pub struct ChildIndexIter<'a> {
41    inner: &'a Louds,
42    node: LoudsNodeNum,
43    start: Option<u64>,
44    end: Option<u64>,
45}
46/// A node iterator
47pub struct ChildNodeIter<'a>(ChildIndexIter<'a>);
48
49/// An ancestor node iterator
50pub struct AncestorNodeIter<'a> {
51    inner: &'a Louds,
52    node: LoudsNodeNum,
53}