Example #1
0
 private static void ProcessLine(FrequencyDictionary <string> dictionary, string value)
 {
     foreach (var val in LineParser.Parse(value))
     {
         dictionary.Add(val.ToLower());
     }
 }
Example #2
0
        public IDictionary <string, int> Calculate(string fileName)
        {
            var taskList   = new LinkedList <Task>();
            var dictionary = new FrequencyDictionary <string>();

            foreach (var line in File.ReadLines(fileName))
            {
                taskList.AddLast(Task.Factory.StartNew(() => ProcessLine(dictionary, line)));
            }

            Task.WaitAll(taskList.ToArray());

            return(dictionary);
        }