public void WasTyped(string word, int times) { if (String.IsNullOrEmpty(word)) { this.popularity += times; return; } this.popularity += times; word = word.ToLower(); var firstChar = word[0]; var postfix = word.Substring(1); if (Trie.IsLatinLetter(firstChar) == false) { return; } if (this.subTries[firstChar] == null) { this.subTries[firstChar] = new Trie(); } this.subTries[firstChar].WasTyped(postfix, times); }
public Trie GetSubTrie(char letter) { letter = Char.ToLower(letter); if (Trie.IsLatinLetter(letter) == false) { return(null); } return(this.subTries[letter] != null ? this.subTries[letter] : null); }
public static bool IsValidWord(string word) { foreach (var letter in word) { if (Trie.IsLatinLetter(letter) == false) { return(false); } } return(true); }
public bool ValidCharacter(char character) { return(Trie.IsLatinLetter(character) || Trie.IsWordSeparator(character)); }