示例#1
0
        /// <summary>
        /// Return the next higher key-value pair after given key in this dictionary.
        /// Time complexity: O(log(n)).
        /// </summary>
        /// <returns>Null if the given key does'nt exist or next key does'nt exist.</returns>
        public KeyValuePair <K, V> NextHigher(K key)
        {
            var next = binarySearchTree.NextHigher(new SortedDictionaryNode <K, V>(key, default(V)));

            if (next == null)
            {
                return(default(KeyValuePair <K, V>));
            }

            return(new KeyValuePair <K, V>(next.Key, next.Value));
        }
示例#2
0
 /// <summary>
 /// Return the next higher value after given value in this hashset.
 /// Time complexity: O(log(n)).
 /// </summary>
 /// <returns>Null if the given value does'nt exist or next value does'nt exist.</returns>
 public T Next(T value)
 {
     return(binarySearchTree.NextHigher(value));
 }