示例#1
0
        private static void RunAnagram2B(WrappingWriter writer, List <string> words, List <string> wordTest)
        {
            Stopwatch          swSearch   = new Stopwatch();
            Stopwatch          swElapsed  = new Stopwatch();
            ICombinator <char> combinator = new GenericCombinator <char>();
            Anagram2           anagram    = new Anagram2(combinator, words);

            writer.WriteLine($"{Environment.NewLine}Running Anagram2B");
            swElapsed.Start();
            swSearch.Start();
            var anagrams = anagram.FindAll(wordTest);

            swSearch.Stop();
            foreach (var pair in anagrams)
            {
                writer.Write($"{pair.Key}:");
                foreach (var result in pair.Value)
                {
                    writer.Write($@" {result}");
                }
                writer.WriteLine();
            }
            swElapsed.Stop();

            writer.WriteLine($"{Environment.NewLine}Anagram2B completed! {Environment.NewLine}\tSearchTime:   {swSearch.Elapsed}{Environment.NewLine}\tElapsed Time: {swElapsed.Elapsed}");
            writer.WriteLine($"Number of words: {words.Count}");
            writer.WriteLine($"Number of words to test: {wordTest.Count}");
            writer.WriteLine($"Number of anagram pairs: {anagrams.Count}");
        }
示例#2
0
        private static void RunAnagram2A(WrappingWriter writer, List <string> words, List <string> wordTest)
        {
            Stopwatch          stopwatch  = new Stopwatch();
            ICombinator <char> combinator = new GenericCombinator <char>();
            Anagram2           anagram    = new Anagram2(combinator, words);

            writer.WriteLine($"{Environment.NewLine}Running Anagram2A");
            stopwatch.Start();
            foreach (var word in wordTest)
            {
                writer.Write($"{word}:");
                var results = anagram.FindAll(word);
                foreach (var result in results)
                {
                    writer.Write($@" {result}");
                }
                writer.WriteLine();
            }
            stopwatch.Stop();
            writer.WriteLine($"{Environment.NewLine}Done in {stopwatch.ElapsedMilliseconds}ms!");
        }