示例#1
0
        void PopOperatorAndPushResult(Stack <TreeNode> termStack, Stack <BinaryOperatorOperation> operatorStack)
        {
            BinaryOperation operation = operatorStack.Pop();
            // note: operators are popped in the reverse order because stack.
            TreeNode rightChild = termStack.Pop();
            TreeNode leftChild  = termStack.Pop();
            TreeNode result     = new BinaryOperationTreeNode(operation, leftChild, rightChild);

            termStack.Push(result);
        }
示例#2
0
        private TreeNode MakeBinaryDifferential(BinaryOperationTreeNode bTreeNode, int index)
        {
            TreeNode leftChildDx  = MakeDifferential(bTreeNode.LeftChild, index);
            TreeNode rightChildDx = MakeDifferential(bTreeNode.RightChild, index);
            TreeNode differential = BinaryDifferential[bTreeNode.Operation].Clone();

            ReplaceDifferentialArguments(differential, bTreeNode.LeftChild, leftChildDx, bTreeNode.RightChild, rightChildDx);

            return(differential);
        }