Esempio n. 1
0
        public void Add(SortedTrieNode node, FWord fWord, int pos)
        {
            while (true)
            {
                if (pos != 0)
                {
                    node._words.Add(fWord);
                }

                if (pos == fWord.Word.Length)
                {
                    return;
                }

                var firstChar = fWord.Word[pos];
                var index     = (int)(firstChar - 'a');
                if (node._children[index] == null)
                {
                    node._children[index] = new SortedTrieNode();
                }

                node = node._children[index];
                pos  = ++pos;
            }
        }
Esempio n. 2
0
        public IEnumerable <FWord> Prefix(string prefix, SortedTrieNode node)
        {
            while (true)
            {
                if (prefix == "")
                {
                    return(node._words);
                }

                var firstChar = prefix[0];
                var index     = (int)(firstChar - 'a');
                if (node._children[index] == null)
                {
                    return(EmptySet);
                }

                prefix = prefix.Substring(1);
                node   = node._children[index];
            }
        }
Esempio n. 3
0
 public FDictionary()
 {
     _node = new SortedTrieNode();
 }
Esempio n. 4
0
 /// <summary>
 /// Удалить все слова из словаря
 /// </summary>
 public void Clear()
 {
     _node = new SortedTrieNode();
 }