public SimpleTreeNode <T> Add(T Value)
        {
            SimpleTreeNode <T> Node = new SimpleTreeNode <T>(Parent);

            Node.Value = Value;
            return(Node);
        }
Beispiel #2
0
        // TODO: adjust for traversal direction
        private IEnumerable <SimpleTreeNode <T> > GetBreadthFirstEnumerable(TreeTraversalDirection TraversalDirection)
        {
            if (TraversalDirection == TreeTraversalDirection.BottomUp)
            {
                var stack = new Stack <SimpleTreeNode <T> >();
                foreach (var item in GetBreadthFirstEnumerable(TreeTraversalDirection.TopDown))
                {
                    stack.Push(item);
                }
                while (stack.Count > 0)
                {
                    yield return(stack.Pop());
                }
                yield break;
            }

            var queue = new Queue <SimpleTreeNode <T> >();

            queue.Enqueue(this);

            while (0 < queue.Count)
            {
                SimpleTreeNode <T> node = queue.Dequeue();

                foreach (SimpleTreeNode <T> child in node.Children)
                {
                    queue.Enqueue(child);
                }

                yield return(node);
            }
        }
 public new SimpleTreeNode <T> Add(SimpleTreeNode <T> Node)
 {
     base.Add(Node);
     Node.Parent = Parent;
     return(Node);
 }
 public SimpleTreeNodeList(SimpleTreeNode <T> Parent)
 {
     this.Parent = Parent;
 }
Beispiel #5
0
 public SimpleTreeNode(SimpleTreeNode <T> Parent, SimpleTreeNodeList <T> Children)
 {
     this.Parent     = Parent;
     this.Children   = Children;
     Children.Parent = this;
 }
Beispiel #6
0
 public SimpleTreeNode(SimpleTreeNode <T> Parent)
 {
     this.Parent = Parent;
     Children    = new SimpleTreeNodeList <T>(this);
 }