示例#1
0
        private static void LookUp(string searchString, IGenericSuffixTrie <char, int> trie)
        {
            Console.WriteLine("----------------------------------------");
            Console.WriteLine("Look-up for string '{0}'", searchString);
            var stopWatch = new Stopwatch();

            stopWatch.Start();

            var result = trie.RetrieveSubstrings(searchString.AsSpan()).ToArray();

            stopWatch.Stop();

            string matchesText  = String.Join(",", result);
            int    matchesCount = result.Count();

            if (matchesCount == 0)
            {
                Console.WriteLine("No matches found.\tTime: {0}", stopWatch.Elapsed);
            }
            else
            {
                Console.WriteLine(" {0} matches found. \tTime: {1}\tLines: {2}", matchesCount, stopWatch.Elapsed,
                                  matchesText);
            }
        }
示例#2
0
        private static void BuildUp(string fileName, IGenericSuffixTrie <char, int> trie)
        {
            IEnumerable <WordAndLine> allWordsInFile = GetWordsFromFile(fileName);
            int i = 0;

            foreach (WordAndLine wordAndLine in allWordsInFile)
            {
                trie.Add(wordAndLine.Word.AsMemory(), ++i);
            }
        }