private static void Test(ISubstringsFinder algo, string text, string pattern, List <int> expected)
        {
            var actual = algo.FindAll(text, pattern);

            Assert.AreEqual(expected.Count, actual.Count);
            for (var i = 0; i < actual.Count; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
Beispiel #2
0
        private static void Solve(string pattern, string text, ISubstringsFinder algo)
        {
            var sw = new Stopwatch();

            sw.Start();

            var res = algo.FindAll(text, pattern);

            sw.Stop();

            Console.WriteLine("Count: {0}", res.Count);
            Console.WriteLine("Time: {0}", sw.ElapsedMilliseconds);
            //foreach (var x in algo.FindAll(text, pattern))
            //    Console.Write(x + " ");

            GC.Collect();
        }