/// <summary> /// Enumerates ring starting at key following x. /// Skips duplicate values. /// </summary> public IEnumerable <KeyValuePair <TKey, TValue> > EnumerateFromNearestDistinct(TKey key) { var items = new HashSet <TValue>(); var nearest = GetNearest(key, _root); var enumerator = new EnumeratorIncreasing(_root, nearest, _comparer); while (enumerator.MoveNext()) { if (items.Add(enumerator.Current.Value)) { yield return(enumerator.Current); } } enumerator = new EnumeratorIncreasing(_root); while (enumerator.MoveNext()) { if (_comparer(enumerator.Current.Key, nearest.Key) == 0) { yield break; } if (items.Add(enumerator.Current.Value)) { yield return(enumerator.Current); } } }
/// <summary> /// Enumerates ring starting at key following x. /// </summary> public IEnumerable <KeyValuePair <TKey, TValue> > EnumerateFromNearest(TKey x) { var nearest = GetNearest(x, _root); var enumerator = new EnumeratorIncreasing(_root, nearest, _comparer); while (enumerator.MoveNext()) { yield return(enumerator.Current); } enumerator = new EnumeratorIncreasing(_root); while (enumerator.MoveNext()) { if (_comparer(enumerator.Current.Key, nearest.Key) == 0) { yield break; } yield return(enumerator.Current); } }