[][src]Struct crdt_tree::tree::Tree

pub struct Tree<ID: TreeId, TM: TreeMeta> { /* fields omitted */ }

From the paper:

We can represent the tree as a set of (parent, meta, child) triples, denoted in Isabelle/HOL as (’n × ’m × ’n) set. When we have (p, m, c) ∈ tree, that means c is a child of p in the tree, with associated metadata m. Given a tree, we can construct a new tree’ in which the child c is moved to a new parent p, with associated metadata m, as follows:

tree’ = {(p’, m’, c’) ∈ tree. c’ != c} ∪ {(p, m, c)}

That is, we remove any existing parent-child relationship for c from the set tree, and then add {(p, m, c)} to represent the new parent-child relationship.

Implementations

impl<ID: TreeId, TM: TreeMeta> Tree<ID, TM>[src]

pub fn new() -> Self[src]

create a new Tree instance

pub fn rm_child(&mut self, child_id: &ID)[src]

helper for removing a triple based on child_id

pub fn rm_subtree(&mut self, parent_id: &ID, include_parent: bool)[src]

removes a subtree. useful for emptying trash. not used by crdt algo.

pub fn add_node(&mut self, child_id: ID, tt: TreeNode<ID, TM>)[src]

adds a node to the tree

pub fn find(&self, child_id: &ID) -> Option<&TreeNode<ID, TM>>[src]

returns matching node, or None.

pub fn children(&self, parent_id: &ID) -> Vec<ID>[src]

returns children (IDs) of a given parent node. useful for walking tree. not used by crdt algo.

pub fn walk<F>(&self, parent_id: &ID, f: &F) where
    F: Fn(&Self, &ID, usize), 
[src]

walks tree and calls callback fn for each node. not used by crdt algo.

pub fn is_ancestor(&self, child_id: &ID, ancestor_id: &ID) -> bool[src]

parent | child

1 2 1 3 3 5 2 6 6 8 1 2 3 6 5 8

is 2 ancestor of 8? yes. is 2 ancestor of 5? no. determines if ancestor_id is an ancestor of node_id in tree. returns bool

Trait Implementations

impl<ID: Clone + TreeId, TM: Clone + TreeMeta> Clone for Tree<ID, TM>[src]

impl<ID: Debug + TreeId, TM: Debug + TreeMeta> Debug for Tree<ID, TM>[src]

impl<ID: Default + TreeId, TM: Default + TreeMeta> Default for Tree<ID, TM>[src]

impl<'de, ID: TreeId, TM: TreeMeta> Deserialize<'de> for Tree<ID, TM> where
    ID: Deserialize<'de>,
    TM: Deserialize<'de>, 
[src]

impl<ID: Eq + TreeId, TM: Eq + TreeMeta> Eq for Tree<ID, TM>[src]

impl<ID: TreeId, TM: TreeMeta> IntoIterator for Tree<ID, TM>[src]

Implement IntoIterator for Tree. This is useful for walking all Nodes in tree without knowing a starting point.

type Item = (ID, TreeNode<ID, TM>)

The type of the elements being iterated over.

type IntoIter = IntoIter<ID, TreeNode<ID, TM>>

Which kind of iterator are we turning this into?

impl<ID: PartialEq + TreeId, TM: PartialEq + TreeMeta> PartialEq<Tree<ID, TM>> for Tree<ID, TM>[src]

impl<ID: TreeId, TM: TreeMeta> Serialize for Tree<ID, TM> where
    ID: Serialize,
    TM: Serialize
[src]

impl<ID: TreeId, TM: TreeMeta> StructuralEq for Tree<ID, TM>[src]

impl<ID: TreeId, TM: TreeMeta> StructuralPartialEq for Tree<ID, TM>[src]

Auto Trait Implementations

impl<ID, TM> RefUnwindSafe for Tree<ID, TM> where
    ID: RefUnwindSafe,
    TM: RefUnwindSafe

impl<ID, TM> Send for Tree<ID, TM> where
    ID: Send,
    TM: Send

impl<ID, TM> Sync for Tree<ID, TM> where
    ID: Sync,
    TM: Sync

impl<ID, TM> Unpin for Tree<ID, TM> where
    ID: Unpin,
    TM: Unpin

impl<ID, TM> UnwindSafe for Tree<ID, TM> where
    ID: UnwindSafe,
    TM: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<TM> TreeMeta for TM where
    TM: Clone
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,