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); }
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); }