// a symbol-table client that finds the number of occurrences of each string // (having at least as many characters as a given threshold length) // in a sequence of strings from standard input, // then iterates through the keys to find the one that occurs the most frequently static void FrequencyCounter(ISymbolTable <string, int> st, IEnumerable <string> strings) { foreach (string s in strings) { if (st.Contains(s)) { st.Put(s, 1 + st.Get(s)); } else { st.Put(s, 1); } } }
ISymbolTable <String, Double> GetGrades(string st) { ISymbolTable <String, Double> grades = Factory <String, Double>(st); grades.Put("A", 4.00); grades.Put("B", 3.00); grades.Put("C", 2.00); grades.Put("D", 1.00); grades.Put("F", 0.00); grades.Put("A+", 4.33); grades.Put("B+", 3.33); grades.Put("C+", 2.33); grades.Put("A-", 3.67); grades.Put("B-", 2.67); return(grades); }
private void InitSymbolTable() { _symbolTable.Put("she", 0); _symbolTable.Put("sells", 1); _symbolTable.Put("sea", 2); _symbolTable.Put("shells", 3); _symbolTable.Put("by", 4); _symbolTable.Put("the", 5); _symbolTable.Put("sea", 6); _symbolTable.Put("shore", 7); _symbolTable.Put("a", 8); }