public void TestRangeEnumerate()
        {
            BTreeList <int> data = new BTreeList <int>(Comparer);

            for (int i = 0; i < 100; i++)
            {
                Assert.IsTrue(data.TryAddItem(i));
            }

            int ix = 0;

            foreach (int kv in data.EnumerateRange(-500, 5000))
            {
                Assert.AreEqual(ix++, kv);
            }
            Assert.AreEqual(100, ix);

            foreach (
                KeyValuePair <int, int> range in
                new Dictionary <int, int> {
                { 6, 25 }, { 7, 25 }, { 8, 25 }, { 9, 25 }, { 22, 25 }, { 28, 28 }
            })
            {
                ix = range.Key;
                foreach (int kv in data.EnumerateRange(ix, range.Value))
                {
                    Assert.AreEqual(ix++, kv);
                }
                Assert.AreEqual(range.Value, ix - 1);
            }
        }
        public void TestEnumerateFrom()
        {
            BTreeList <int> data = new BTreeList <int>(Comparer);

            for (int i = 0; i < 100; i++)
            {
                Assert.IsTrue(data.TryAddItem(i));
            }

            Assert.AreEqual(50, new List <int>(data.EnumerateFrom(50)).Count);
            Assert.AreEqual(25, new List <int>(data.EnumerateFrom(75)).Count);

            for (int i = 0; i < 100; i++)
            {
                int first = -1;
                foreach (int kv in data.EnumerateFrom(i))
                {
                    first = kv;
                    break;
                }
                Assert.AreEqual(i, first);
            }
        }
        void SequencedTest(int start, int incr, int stop, string name)
        {
            int count = Math.Abs(start - stop) / Math.Abs(incr);

            BTreeList <int> data = new BTreeList <int>(Comparer);
            Stopwatch       time = new Stopwatch();

            time.Start();
            //large order-forward
            for (int i = start; i != stop; i += incr)
            {
                if (!data.TryAddItem(i))
                {
                    throw new ApplicationException();
                }
            }

            Trace.TraceInformation("{0} insert  {1} in {2}", name, count, time.ElapsedMilliseconds);
            time.Reset();
            time.Start();

            for (int i = start; i != stop; i += incr)
            {
                if (!data.Contains(i))
                {
                    throw new ApplicationException();
                }
            }

            Trace.TraceInformation("{0} seek    {1} in {2}", name, count, time.ElapsedMilliseconds);
            time.Reset();
            time.Start();

            int tmpCount = 0;

            foreach (int tmp in data)
            {
                if (tmp < Math.Min(start, stop) || tmp > Math.Max(start, stop))
                {
                    throw new ApplicationException();
                }
                else
                {
                    tmpCount++;
                }
            }
            if (tmpCount != count)
            {
                throw new ApplicationException();
            }

            Trace.TraceInformation("{0} foreach {1} in {2}", name, count, time.ElapsedMilliseconds);
            time.Reset();
            time.Start();

            for (int i = start; i != stop; i += incr)
            {
                if (!data.Remove(i))
                {
                    throw new ApplicationException();
                }
            }

            Trace.TraceInformation("{0} delete  {1} in {2}", name, count, time.ElapsedMilliseconds);

            for (int i = start; i != stop; i += incr)
            {
                if (data.Contains(i))
                {
                    throw new ApplicationException();
                }
            }
        }