/// <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; } } }
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); }
private IntTree <V> With(IntTree <V> left, IntTree <V> right) { return(new IntTree <V>(Key, Value, left, right)); }
private IntHashTree(IntTree <KV <K, V> > root) { _root = root; }
public TreeAppendStore(int count, IntTree <T[]> tree) { Count = count; _tree = tree; }
private HashTreeX(IntTree <KV <K, V> > tree, Func <V, V, V> updateValue) { _tree = tree; _updateValue = updateValue; }
private TypeTree(IntTree <KV> tree) { _tree = tree; }
private HashTree2(IntTree <KVStack> tree) { _tree = tree; }
private HashTree3(IntTree <KV> tree) { _tree = tree; }