private static Pair ReadMember() { Pair result; var val = peek(); var intValue = (long)val - 48; if (intValue >= 0 && intValue < 10) { read(); // get the number off the queue result = new LeafNode(intValue); } else { result = ParsePair(); } return(result); }
public TreeNode Clone() { Pair newLeft, newRight; if (left is TreeNode) { newLeft = ((TreeNode)left).Clone(); } else { newLeft = new LeafNode(((LeafNode)left).value); } if (right is TreeNode) { newRight = ((TreeNode)right).Clone(); } else { newRight = new LeafNode(((LeafNode)right).value); } return(new TreeNode(newLeft, newRight)); }