static void GetCharCountArray(string str) { for (int i = 0; i < str.Length; i++) { if (hm.ContainsKey(str[i])) { hm[str[i]].IncreaseCount(); } else { hm[str[i]] = new CountIndex(i); } } }
/* calculate count of characters * in the passed string */ public static void getCharCountArray(string str) { for (int i = 0; i < str.Length; i++) { // If character already occurred, if (hm.ContainsKey(str[i])) { // updating count hm[str[i]].incCount(); } // If it's first occurrence, then // store the index and count = 1 else { hm[str[i]] = new CountIndex(i); } } }