Ejemplo n.º 1
0
        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"));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Find the weak predecessor 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 predecessor</returns>
 public T WeakPredecessor(T item)
 {
     return(sorted.WeakPredecessor(item));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Get the entry in the dictionary whose key is the
 /// weak predecessor of the specified key.
 /// </summary>
 /// <exception cref="NoSuchItemException"></exception>
 /// <param name="key">The key</param>
 /// <returns>The entry</returns>
 public KeyValuePair <K, V> WeakPredecessor(K key)
 {
     return(sortedpairs.WeakPredecessor(new KeyValuePair <K, V>(key)));
 }
Ejemplo n.º 4
0
        public KeyValuePair <K, V> WeakPredecessor(K key)
        {
            KeyValuePair <K, V> p = new KeyValuePair <K, V>(key);

            return(sortedpairs.WeakPredecessor(p));
        }