pub enum Event {
Leaf(u32),
Branch(u32, Box<Self>, Box<Self>),
}Expand description
An ITC event tree, tracking causal history as a binary tree of counters.
The effective count at any position is the sum of counters along the root-to-leaf path. Interior nodes carry a base counter that is shared by both subtrees. Normalization lifts the minimum of two children’s leaf values into the parent and collapses uniform branches.
Variants§
Leaf(u32)
Leaf with a counter value.
Branch(u32, Box<Self>, Box<Self>)
Branch with a base counter and left/right subtrees.
The effective value at any leaf in this subtree is base plus
the value accumulated through the child path.
Implementations§
Source§impl Event
impl Event
Sourcepub fn branch(base: u32, left: Self, right: Self) -> Self
pub fn branch(base: u32, left: Self, right: Self) -> Self
Create a branch, automatically normalizing degenerate cases.
Normalization rules:
Branch(n, Leaf(a), Leaf(b))wherea == b→Leaf(n + a)- Otherwise, lifts the minimum of leaf children into the base:
Branch(n, l, r)→Branch(n + min, l - min, r - min)
Sourcepub const fn value(&self) -> u32
pub const fn value(&self) -> u32
The base value at this node.
For leaves, this is the counter value. For branches, the base counter.
Sourcepub fn min_value(&self) -> u32
pub fn min_value(&self) -> u32
The minimum effective value in the entire subtree.
For leaves, this is just the counter. For branches, it is the base plus the minimum of the two children’s minimums.
Sourcepub fn max_value(&self) -> u32
pub fn max_value(&self) -> u32
The maximum effective value in the entire subtree.
For leaves, this is just the counter. For branches, it is the base plus the maximum of the two children’s maximums.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of nodes in the tree (leaves + branches).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Event
impl<'de> Deserialize<'de> for Event
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>,
impl Eq for Event
impl StructuralPartialEq for Event
Auto Trait Implementations§
impl Freeze for Event
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnsafeUnpin for Event
impl UnwindSafe for Event
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.