public void Add(string value, double score) { if (!_hash.TryGetValue(value, out var entry)) { entry = new SortedSetEntry <string>(value) { Score = score }; _value.Add(entry); _hash.Add(value, entry); } else { // Element already exists, just need to add a score value – re-create it. _value.Remove(entry); entry.Score = score; _value.Add(entry); } }
public int Compare(SortedSetEntry <T> x, SortedSetEntry <T> y) { if (ReferenceEquals(x, y)) { return(0); } if (ReferenceEquals(null, y)) { return(1); } if (ReferenceEquals(null, x)) { return(-1); } var scoreComparison = x.Score.CompareTo(y.Score); if (scoreComparison != 0) { return(scoreComparison); } return(x.Value.CompareTo(y.Value)); }