示例#1
0
文件: Trie.cs 项目: Cloudxtreme/anima
        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);
        }
示例#2
0
文件: Trie.cs 项目: Cloudxtreme/anima
        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);
        }
示例#3
0
文件: Trie.cs 项目: Cloudxtreme/anima
        public static bool IsValidWord(string word)
        {
            foreach (var letter in word)
            {
                if (Trie.IsLatinLetter(letter) == false)
                {
                    return(false);
                }
            }

            return(true);
        }
示例#4
0
 public bool ValidCharacter(char character)
 {
     return(Trie.IsLatinLetter(character) || Trie.IsWordSeparator(character));
 }