Exemplo n.º 1
0
        IList <int> GetParentsBelowStackBased(TreeElement searchFromThis)
        {
            Stack <TreeElement> stack = new Stack <TreeElement>();

            stack.Push(searchFromThis);

            var parentsBelow = new List <int>();

            while (stack.Count > 0)
            {
                TreeElement current = stack.Pop();
                if (current.HasChildren)
                {
                    parentsBelow.Add(current.ID);
                    foreach (var T in current.Children)
                    {
                        stack.Push(T);
                    }
                }
            }

            return(parentsBelow);
        }
Exemplo n.º 2
0
        public void AddElement(T element, TreeElement parent, int insertPosition)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element", "element is null");
            }
            if (parent == null)
            {
                throw new ArgumentNullException("parent", "parent is null");
            }

            if (parent.Children == null)
            {
                parent.Children = new List <TreeElement> ();
            }

            parent.Children.Insert(insertPosition, element);
            element.Parent = parent;

            TreeElementUtility.UpdateDepthValues(parent);
            TreeElementUtility.TreeToList(m_Root, m_Data);

            Changed();
        }