예제 #1
0
        // Find (strict) predecessor of y in coll, or return false

        public static bool Predecessor <T>(ISorted <T> coll, T y, out T yPred)
            where T : IComparable <T>
        {
            coll.Cut(y, out yPred, out var hasPred, out _, out _);

            return(hasPred);
        }
예제 #2
0
        // Find (strict) successor of y in coll, or return false

        public static bool Successor <T>(ISorted <T> coll, T y, out T ySucc)
            where T : IComparable <T>
        {
            coll.Cut(y, out _, out _, out ySucc, out var hasSucc);

            return(hasSucc);
        }
        // Find (strict) predecessor of y in coll, or return false

        public static bool Predecessor <T>(ISorted <T> coll, T y, out T yPred)
            where T : IComparable <T>
        {
            bool hasPred, hasSucc;
            T    ySucc;

            coll.Cut(y, out yPred, out hasPred, out ySucc, out hasSucc);
            return(hasPred);
        }
예제 #4
0
        // Find weak predecessor of y in coll, or return false

        public static bool WeakPredecessor <T>(ISorted <T> coll, T y, out T yPred)
            where T : IComparable <T>
        {
            bool hasPred, hasY = coll.Cut(y, out yPred, out hasPred, out _, out _);

            if (hasY)
            {
                yPred = y;
            }
            return(hasY || hasPred);
        }
예제 #5
0
        // --- Predecessor and successor patterns --------------------

        // Find weak successor of y in coll, or return false

        public static bool WeakSuccessor <T>(ISorted <T> coll, T y, out T ySucc)
            where T : IComparable <T>
        {
            var hasY = coll.Cut(y, out _, out _, out ySucc, out var hasSucc);

            if (hasY)
            {
                ySucc = y;
            }

            return(hasY || hasSucc);
        }
        // --- Predecessor and successor patterns --------------------

        // Find weak successor of y in coll, or return false

        public static bool WeakSuccessor <T>(ISorted <T> coll, T y, out T ySucc)
            where T : IComparable <T>
        {
            T    yPred;
            bool hasPred, hasSucc,
                 hasY = coll.Cut(y, out yPred, out hasPred, out ySucc, out hasSucc);

            if (hasY)
            {
                ySucc = y;
            }
            return(hasY || hasSucc);
        }
예제 #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cutter"></param>
 /// <param name="lowEntry"></param>
 /// <param name="lowIsValid"></param>
 /// <param name="highEntry"></param>
 /// <param name="highIsValid"></param>
 /// <returns></returns>
 public bool Cut(IComparable <K> cutter, out KeyValuePair <K, V> lowEntry, out bool lowIsValid, out KeyValuePair <K, V> highEntry, out bool highIsValid)
 {
     return(sortedpairs.Cut(new KeyValuePairComparable(cutter), out lowEntry, out lowIsValid, out highEntry, out highIsValid));
 }
예제 #8
0
 /// <summary>
 /// Run Cut on the wrapped sorted collection
 /// </summary>
 /// <param name="c"></param>
 /// <param name="low"></param>
 /// <param name="lval"></param>
 /// <param name="high"></param>
 /// <param name="hval"></param>
 /// <returns></returns>
 public bool Cut(IComparable <T> c, out T low, out bool lval, out T high, out bool hval)
 {
     return(sorted.Cut(c, out low, out lval, out high, out hval));
 }