Esempio n. 1
0
        /// <summary>Depth-first in-order traversal as described in http://en.wikipedia.org/wiki/Tree_traversal
        /// The only difference is using fixed size array instead of stack for speed-up (~20% faster than stack).</summary>
        public IEnumerable <IntTree <V> > Enumerate()
        {
            if (Height == 0)
            {
                yield break;
            }
            var parents     = new IntTree <V> [Height];
            var parentCount = -1;
            var node        = this;

            while (!node.IsEmpty || parentCount != -1)
            {
                if (!node.IsEmpty)
                {
                    parents[++parentCount] = node;
                    node = node.Left;
                }
                else
                {
                    node = parents[parentCount--];
                    yield return(node);

                    node = node.Right;
                }
            }
        }
Esempio n. 2
0
 private IntTree(int key, V value, IntTree <V> left, IntTree <V> right)
 {
     Key    = key;
     Value  = value;
     Left   = left;
     Right  = right;
     Height = 1 + (left.Height > right.Height ? left.Height : right.Height);
 }
Esempio n. 3
0
 private IntTree <V> With(IntTree <V> left, IntTree <V> right)
 {
     return(new IntTree <V>(Key, Value, left, right));
 }
Esempio n. 4
0
 private IntHashTree(IntTree <KV <K, V> > root)
 {
     _root = root;
 }
Esempio n. 5
0
 public TreeAppendStore(int count, IntTree <T[]> tree)
 {
     Count = count;
     _tree = tree;
 }
Esempio n. 6
0
 private HashTreeX(IntTree <KV <K, V> > tree, Func <V, V, V> updateValue)
 {
     _tree        = tree;
     _updateValue = updateValue;
 }
Esempio n. 7
0
 private TypeTree(IntTree <KV> tree)
 {
     _tree = tree;
 }
 private HashTree2(IntTree <KVStack> tree)
 {
     _tree = tree;
 }
 private HashTree3(IntTree <KV> tree)
 {
     _tree = tree;
 }