Exemplo n.º 1
0
        public SimpleTreeNode <T> Add(T Value)
        {
            SimpleTreeNode <T> Node = new SimpleTreeNode <T>(Parent);

            Node.Value = Value;
            return(Node);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 3
0
 public new SimpleTreeNode <T> Add(SimpleTreeNode <T> Node)
 {
     base.Add(Node);
     Node.Parent = Parent;
     return(Node);
 }
Exemplo n.º 4
0
 public SimpleTreeNodeList(SimpleTreeNode <T> Parent)
 {
     this.Parent = Parent;
 }
Exemplo n.º 5
0
 public SimpleTreeNode(SimpleTreeNode <T> Parent)
 {
     this.Parent = Parent;
     Children    = new SimpleTreeNodeList <T>(this);
 }
Exemplo n.º 6
0
 public SimpleTreeNode(SimpleTreeNode <T> Parent, SimpleTreeNodeList <T> Children)
 {
     this.Parent     = Parent;
     this.Children   = Children;
     Children.Parent = this;
 }