/// <summary> /// Return the next lower key-value pair before given key in this dictionary. /// Time complexity: O(log(n)). /// </summary> /// <returns>Null if the given key does'nt exist or previous key does'nt exist.</returns> public KeyValuePair <K, V> NextLower(K key) { var prev = binarySearchTree.NextLower(new SortedDictionaryNode <K, V>(key, default(V))); if (prev == null) { return(default(KeyValuePair <K, V>)); } return(new KeyValuePair <K, V>(prev.Key, prev.Value)); }
/// <summary> /// Return the next lower value before given value in this HashSet. /// Time complexity: O(log(n)). /// </summary> /// <returns>Null if the given value does'nt exist or previous value does'nt exist.</returns> public T Previous(T value) { return(binarySearchTree.NextLower(value)); }