namespace TranscriptAnalysis { public class OccuranceMap { private readonly Dictionary map = new Dictionary(); public void Add(int point) { if (map.ContainsKey(point)) { map[point]++; } else { map.Add(point, 1); } } public void Print(Action action) { Print(false, action); } public void PrintContinous(Action action) { Print(true, action); } private void Print(bool continuous, Action action) { var min = map.Keys.Min(); var max = map.Keys.Max(); for (var i = min; i <= max; i++) { if (map.ContainsKey(i)) { action(i, map[i]); } else if (continuous) { action(i, 0); } } } } }