public void Add(WordContainer container) { for (int i = 0; i < Children.Count; i++) { if (Children [i].IsParentOf (container)) { Children [i].Add (container); return; } if (Children [i].IsChildOf (container)) { container.Add (Children [i]); Children.RemoveAt (i); i--; } } Children.Add (container); }
public bool IsChildOf(WordContainer newWord) { if (newWord.Word.Value.Length > Word.Value.Length) { return(false); } return(newWord.Word.Value == Word.Value.Substring(0, newWord.Word.Value.Length)); }
public bool IsParentOf(WordContainer newWord) { if (newWord.Word.Value.Length < Word.Value.Length) { return(false); } return(Word.Value == newWord.Word.Value.Substring(0, Word.Value.Length)); }
public bool IsChildOf(WordContainer newWord) { if (newWord.Word.Value.Length > Word.Value.Length ) { return false; } return newWord.Word.Value == Word.Value.Substring(0,newWord.Word.Value.Length); }
public bool IsParentOf(WordContainer newWord) { if (newWord.Word.Value.Length < Word.Value.Length ) { return false; } return Word.Value == newWord.Word.Value.Substring(0,Word.Value.Length); }
public IList <WordContainer> Matches(WordContainer word) { IList <WordContainer> matches = new List <WordContainer> (); foreach (WordContainer child in Children) { if (word.IsChildOf(child)) { return(child.Matches(word)); } else if (word.Word.Value == child.Word.Value) { matches.Add(word); } } return(matches); }
public void Add(WordContainer container) { for (int i = 0; i < Children.Count; i++) { if (Children [i].IsParentOf(container)) { Children [i].Add(container); return; } if (Children [i].IsChildOf(container)) { container.Add(Children [i]); Children.RemoveAt(i); i--; } } Children.Add(container); }
public IList<WordContainer> Matches(WordContainer word) { IList<WordContainer> matches = new List<WordContainer> (); foreach (WordContainer child in Children) { if (word.IsChildOf (child)) { return child.Matches (word); } else if (word.Word.Value == child.Word.Value) { matches.Add (word); } } return matches; }
public DefaultDictionary() { m_tree = new WordContainer(new DefaultWord("", null, 0)); }
public DefaultDictionary () { m_tree = new WordContainer (new DefaultWord ("", null, 0)); }