public void TestPerformance()
        {
            var            rand = new Random(0);
            IList <object> list = new UnorderedRedBlackList <object> {
                Enumerable.Repeat <object>(null, 100000)
            };
            var alist = new List <object>();

            alist.AddRange(list);

            int ops = 0;
            var sw  = new Stopwatch();

            sw.Start();
            for (int i = 0; i < 100; i++)
            {
                bool insert = list.Count < 5000 || list.Count < 20000 && rand.Next(2) == 0;
                int  n      = rand.Next(1, insert ? list.Count : list.Count / 2);
                for (int j = 0; j < n; j++)
                {
                    if (insert)
                    {
                        list.Insert(rand.Next(list.Count + 1), null);
                    }
                    else
                    {
                        list.RemoveAt(rand.Next(list.Count));
                    }
                }
                ops += n;
            }
            long t1 = sw.ElapsedMilliseconds;

            rand = new Random(0);
            list = alist;
            sw.Restart();
            for (int i = 0; i < 100; i++)
            {
                bool insert = list.Count < 5000 || list.Count < 20000 && rand.Next(2) == 0;
                int  n      = rand.Next(1, insert ? list.Count : list.Count / 2);
                for (int j = 0; j < n; j++)
                {
                    if (insert)
                    {
                        list.Insert(rand.Next(list.Count + 1), null);
                    }
                    else
                    {
                        list.RemoveAt(rand.Next(list.Count));
                    }
                }
            }
            long t2 = sw.ElapsedMilliseconds;

            Logger.LogMessage("Op Count : {0}", ops);
            Logger.LogMessage("Red-Black: {0}ms", t1);
            Logger.LogMessage("List     : {0}ms", t2);
            Assert.IsTrue(t1 * 2 < t2, "Not fast enough. {0}ms vs {1}ms", t1, t2);
        }
        public void TestList()
        {
            var rand = new Random(0);
            var list = new UnorderedRedBlackList <int> {
                Enumerable.Repeat(0, 1000)
            };

            for (int i = 0; i < 50; i++)
            {
                bool insert = list.Count < 100 || list.Count < 2000 && rand.Next(2) == 0;
                int  n      = rand.Next(1, insert ? list.Count : list.Count / 2);
                for (int j = 0; j < n; j++)
                {
                    if (insert)
                    {
                        list.Insert(rand.Next(list.Count + 1), 0);
                    }
                    else
                    {
                        list.RemoveAt(rand.Next(list.Count));
                    }

                    Verify(list);
                }
                Logger.LogMessage("Size {0}", list.Count);
            }
        }