public static void Add <TKey>(this IStatistic <TKey> stat, IEnumerable <KeyValuePair <TKey, int> > pairs) { foreach (var pair in pairs) { stat.Add(pair.Key, pair.Value); } }
public static void ReadFromCsv <TKey>(this IStatistic <TKey> stat, TextReader reader, Func <string, TKey> keyParser) { stat.Clear(); while (reader.Peek() != -1) { var ss = reader.ReadLine().Split(','); var key = keyParser(ss[0]); var freq = int.Parse(ss[1]); stat.Add(key, freq); } }