public void KeysISortedPred() { ISorted <string> keys = dict.Keys; String res; Assert.IsTrue(keys.TryPredecessor("S", out res)); Assert.AreEqual("R", res); Assert.IsTrue(keys.TryWeakPredecessor("R", out res)); Assert.AreEqual("R", res); Assert.IsTrue(keys.TrySuccessor("S", out res)); Assert.AreEqual("T", res); Assert.IsTrue(keys.TryWeakSuccessor("T", out res)); Assert.AreEqual("T", res); Assert.IsFalse(keys.TryPredecessor("R", out res)); Assert.AreEqual(null, res); Assert.IsFalse(keys.TryWeakPredecessor("P", out res)); Assert.AreEqual(null, res); Assert.IsFalse(keys.TrySuccessor("T", out res)); Assert.AreEqual(null, res); Assert.IsFalse(keys.TryWeakSuccessor("U", out res)); Assert.AreEqual(null, res); Assert.AreEqual("R", keys.Predecessor("S")); Assert.AreEqual("R", keys.WeakPredecessor("R")); Assert.AreEqual("T", keys.Successor("S")); Assert.AreEqual("T", keys.WeakSuccessor("T")); }
/// <summary> /// Get the entry in the dictionary whose key is the /// weak successor of the specified key. /// </summary> /// <exception cref="NoSuchItemException"></exception> /// <param name="key">The key</param> /// <returns>The entry</returns> public KeyValuePair <K, V> WeakSuccessor(K key) { return(sortedpairs.WeakSuccessor(new KeyValuePair <K, V>(key))); }
/// <summary> /// Find the weak Successor of the item in the wrapped sorted collection /// </summary> /// <exception cref="NoSuchItemException"> if no such element exists </exception> /// <param name="item">The item</param> /// <returns>The weak Successor</returns> public T WeakSuccessor(T item) { return(sorted.WeakSuccessor(item)); }