Example #1
0
        public decimal EvaluateTree(NewTree tree)
        {
            Node    top = tree.GetTop();
            decimal ans = PackNode(top).value.Number ?? 0;

            return(ans);
        }
Example #2
0
        //加一棵子樹進來
        public void Add(NewTree tree)
        {
            //如果是第一個數字
            if (Root == null)
            {
                this.Root        = tree.Root;
                this.CurrentNode = tree.CurrentNode;
            }

            if (CurrentNode.IsOperator())
            {
                Node topNode = tree.GetTop();
                CurrentNode.RightNode = topNode;
                topNode.ParentNode    = CurrentNode;

                //主樹現有node必須是子樹的頂端
                CurrentNode = topNode;
            }
        }