示例#1
0
        internal int GetBytes(long ts, int millis)
        {
            var pair   = GetTimestampRange(ts, millis);
            var bottom = new Pair()
            {
                ts = pair.Item1, bytes = 0
            };
            var top = new Pair()
            {
                ts = pair.Item2, bytes = 0
            };
            var iter = list.RangeFromTo(bottom, top);

            return(iter.Select(p => p.bytes).Sum());
        }
示例#2
0
        // Iterate over ]x1...x2[
        public static void IterExcExc <T>(ISorted <T> coll, T x1, T x2)
            where T : IComparable <T>
        {
            bool x1HasSucc = Successor(coll, x1, out T x1Succ);
            IDirectedEnumerable <T> range = x1HasSucc ? coll.RangeFromTo(x1Succ, x2) : new ArrayList <T>();

            Print(range);
        }
示例#3
0
        // Iterate over [x1...x2]
        public static void IterIncInc <T>(ISorted <T> coll, T x1, T x2)
            where T : IComparable <T>
        {
            var x2HasSucc = Successor(coll, x2, out var x2Succ);
            IDirectedEnumerable <T> range = x2HasSucc ? coll.RangeFromTo(x1, x2Succ) : coll.RangeFrom(x1);

            Print(range);
        }
        // Iterate over [x1,x2[, backwards

        public static void IterIncExcBackwards <T>(ISorted <T> coll, T x1, T x2)
        {
            foreach (T x in coll.RangeFromTo(x1, x2).Backwards())
            {
                Console.Write("{0} ", x);
            }
            Console.WriteLine();
        }
示例#5
0
        // Iterate over ]x1...x2[

        public static void IterExcExc <T>(ISorted <T> coll, T x1, T x2)
            where T : IComparable <T>
        {
            bool x1HasSucc = Successor(coll, x1, out T x1Succ);
            IDirectedEnumerable <T> range =
                x1HasSucc ? coll.RangeFromTo(x1Succ, x2) : new ArrayList <T>();

            foreach (T x in range)
            {
                Console.Write("{0} ", x);
            }
            Console.WriteLine();
        }
示例#6
0
        // Iterate over [x1...x2]

        public static void IterIncInc <T>(ISorted <T> coll, T x1, T x2)
            where T : IComparable <T>
        {
            bool x2HasSucc = Successor(coll, x2, out T x2Succ);
            IDirectedEnumerable <T> range =
                x2HasSucc ? coll.RangeFromTo(x1, x2Succ) : coll.RangeFrom(x1);

            foreach (T x in range)
            {
                Console.Write("{0} ", x);
            }
            Console.WriteLine();
        }
示例#7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="bot"></param>
 /// <param name="top"></param>
 /// <returns></returns>
 public IDirectedEnumerable <KeyValuePair <K, V> > RangeFromTo(K bot, K top)
 {
     return(sortedpairs.RangeFromTo(new KeyValuePair <K, V>(bot), new KeyValuePair <K, V>(top)));
 }
示例#8
0
        // Iterate over [x1,x2[, backwards
        public static void IterIncExcBackwards <T>(ISorted <T> coll, T x1, T x2)
        {
            var range = coll.RangeFromTo(x1, x2).Backwards();

            Print(range);
        }
示例#9
0
 /// <summary>
 /// Get the specified range from the wrapped collection.
 /// (The current implementation erroneously does not wrap the result.)
 /// </summary>
 /// <param name="bot"></param>
 /// <param name="top"></param>
 /// <returns></returns>
 public IDirectedEnumerable <T> RangeFromTo(T bot, T top)
 {
     return(sorted.RangeFromTo(bot, top));
 }