public string Serialized() { string output = string.Empty; DictionarySorter <T> .SortDictionary(Scores); foreach (T t in Scores.Keys) { output += t.ToString() + "\t" + Scores[t].ToString() + "\n"; } return(output); }
public bool Process(T item, double score) { // just a check... if (score < WorstScore && Scores.Count >= NKeep) { return(false); } else if (Scores.ContainsKey(item)) { throw new Exception("Item already exists in scores."); } else { Scores.Add(item, score); if (Scores.Count > NKeep) { WorstScore = double.MaxValue; foreach (KeyValuePair <T, double> kvp in Scores) { if (kvp.Value <= WorstScore) { WorstScore = kvp.Value; worstResult = kvp.Key; } } Scores.Remove(worstResult); } DictionarySorter <T> .SortDictionary(Scores); return(true); } // find new worst result //WorstScore = double.MaxValue; //foreach (KeyValuePair<T, double> kvp in Scores) //{ // if (kvp.Value <= WorstScore) // { // WorstScore = kvp.Value; // worstResult = kvp.Key; // } // }