Esempio n. 1
0
        public void InsertRight(OperatorTree tree)
        {
            //Make same assertion as above
              if(this.node == null || (this.node != null && this.node.GetType() != typeof(OperatorNode)))
            throw new Exception("Can't attach subtree to node with data or null.");
              if(this.node.GetType() == typeof(OperatorNode) && ((OperatorNode)this.node).Operator.ToUpper() == "NOT")
            throw new Exception("Can't attach things to the right child of a NOT node.");
              right = tree.Clone();
              right.AddDepth(depth);

              right.parent = this;
              this.size += right.size;
        }
Esempio n. 2
0
 public void InsertLeft(OperatorTree tree)
 {
     //Assert that this OperatorTree's node is not Data and an operator node.
       //Operator nodes are only allowed as interior nodes,
       //Data nodes are only allowed as leaf nodes.
       if(this.node == null || (this.node != null && this.node.GetType() != typeof(OperatorNode)))
     throw new Exception("Can't attach subtree to node with data or null.");
       left = tree.Clone();
       left.AddDepth(depth);
       left.parent = this;
       this.size += left.size;
 }