FoscTreeNode

Returns a FoscTreeNode.


Description

A tree node.


Attributes Summary

Instance Properties

depth
depthwiseInventory A dictionary of all nodes in a rhythm-tree, organized by their depth relative the root node.
index
improperParentage The improper parentage of a node in a rhythm-tree, being the sequence of node beginning with itself and ending with the root node of the tree.
isRoot
properParentage The proper parentage of a node in a rhythm-tree, being the sequence of node beginning with the node’s immediate parent and ending with the root node of the tree.
root
siblings


Instance Properties


depth


depthwiseInventory

A dictionary of all nodes in a rhythm-tree, organized by their depth relative the root node.

Returns dictionary.

  1. Example

    a = FoscTreeContainer(name: 'a');
    b = FoscTreeContainer(name: 'b');
    c = FoscTreeContainer(name: 'c');
    d = FoscTreeContainer(name: 'd');
    e = FoscTreeContainer(name: 'e');
    f = FoscTreeContainer(name: 'f');
    g = FoscTreeContainer(name: 'g');
    
    a.addAll([b, c]);
    b.addAll([d, e]);
    c.addAll([f, g]);
    
    i = a.depthwiseInventory;
    k = i.keys.as(Array).sort;
    o = [];
    k.do { |depth, items|
        o = o.add("depth: %".format(depth));
        i[depth].do { |node|
            o = o.add("%%".format("".padLeft(depth, "\t"), node.name));
        };
    };
    o.join("\n");
    depth: 0
    a
    depth: 1
        b
        c
    depth: 2
            d
            e
            f
            g


index


improperParentage

The improper parentage of a node in a rhythm-tree, being the sequence of node beginning with itself and ending with the root node of the tree.

Returns array of tree nodes.

  1. Example

    a = FoscTreeContainer();
    b = FoscTreeContainer();
    c = FoscTreeNode();
    a.add(b);
    b.add(c);
    
    a.improperParentage == [a];         // true
    true
    b.improperParentage == [b, a];      // true
    true
    c.improperParentage == [c, b, a];   // true
    true


isRoot


properParentage

The proper parentage of a node in a rhythm-tree, being the sequence of node beginning with the node’s immediate parent and ending with the root node of the tree.

Returns array of tree nodes.

  1. Example

    a = FoscTreeContainer();
    b = FoscTreeContainer();
    c = FoscTreeNode();
    a.add(b);
    b.add(c);
    
    a.properParentage == [];            // true
    true
    b.properParentage == [a];           // true
    true
    c.properParentage == [b, a];        // true
    true


root


siblings