bool Add(char[] stack, object accepts) { if (IsBaked) { throw new Exception("Cannot mould a baked tree"); } if (stack.Length == 0) { return(false); } StringTree parent = this; int counter = 0; do { StringTree i = parent.MatchKey(stack[counter++]); if (null == i) { return(AddStackToStringTree(stack, null, parent, --counter, accepts)); } if (null == i.child && counter < stack.Length) { return(AddStackToStringTree(stack, i, null, counter, accepts)); } if (counter == stack.Length) { return(AddStackToStringTree(stack, i, null, counter, accepts)); } parent = i.child; }while (true); }
StringTree GetStringTreeAt(char[] stack) { if (stack == null) { return(null); } if (stack.Length == 0) { return(this); } StringTree parent = this; int counter = 0; do { StringTree i = parent.MatchKey(stack[counter++]); if (null == i) { return(null); } if (null == i.child && counter < stack.Length) { return(null); } if (counter == stack.Length) { return(i); } parent = i.child; }while (true); }