예제 #1
0
 protected TreeNode()
 {
     this.parent = null;
     this.child = null;
     this.sibling = null;
     this.reverse = null;
 }
예제 #2
0
        public static void insert(TreeNode toAdd, TreeNode parent)
        {
            Debug.Assert(parent != null);
            Debug.Assert(toAdd != null);

            toAdd.Parent = parent;
            if (parent.Child == null)
            {
                parent.Child = toAdd;
                toAdd.Parent = parent;
            }
            else
            {
                TreeNode node = parent.Child;
                toAdd.Sibling = node;
                parent.Child = toAdd;
            }
        }
        private GameObject getNext(TreeNode node, bool willUseChild = true)
        {
            TreeNode toRet = null;

            if (current.Child != null)
            {
                toRet = node.Child;
            }
            else if (node.Sibling != null)
            {
                toRet = node.Sibling;
            }
            else if (node.Parent != null && node.Parent != this.treeRoot)
            {
                toRet = getNext(node.Parent, false);
            }

            return (GameObject)toRet;
        }
        public ReverseTreeIterator(TreeNode root)
        {
            Debug.Assert(root != null);
            treeRoot = (GameObject)root;
            current = (GameObject)root;

            GameObject go = treeRoot;
            GameObject node = go;

            while (go != null)
            {
                node = go;
                go = this.next();

                if (go != null)
                {
                    go.Reverse = node;
                }

            }

            this.treeRoot = node;
            this.current = node;
        }
예제 #5
0
 public static void setTree(TreeNode tree)
 {
     Instance.ufoTree = tree;
 }
예제 #6
0
 public static void attachTree(TreeNode root)
 {
     Instance.treeRoot = root;
 }
예제 #7
0
 public static void attachTree(TreeNode node)
 {
     Instance.root = node;
 }
예제 #8
0
 public static void setRoot(TreeNode root)
 {
     Instance.treeRoot = root;
 }