示例#1
0
        public void Clear()
        {
            const int LoopCount  = 10000;
            var       list       = new List <int>();
            var       speedyList = new SpeedyList <int>();

            for (int i = 0; i < LoopCount; i++)
            {
                list.Add(i);
                speedyList.Add(i);
            }
            list.Clear();
            speedyList.Clear();
            Assert.AreEqual(0, speedyList.Count);

            for (int i = 0; i < LoopCount; i++)
            {
                list.Add(i);
                speedyList.Add(i);
            }

            for (int i = 0; i < LoopCount; i++)
            {
                Assert.AreEqual(list[i], speedyList[i]);
            }
        }
示例#2
0
        public void Insert()
        {
            const int LoopCount  = 1000;
            var       list       = new List <int>();
            var       speedyList = new SpeedyList <int>();
            var       random     = new Random();

            for (int i = 0; i < LoopCount; i++)
            {
                int index = random.Next(list.Count);
                int value = random.Next(LoopCount) + 1;
                list.Insert(index, value);
                speedyList.Insert(index, value);
            }
            for (int i = 0; i < LoopCount; i++)
            {
                int index = random.Next(list.Count);
                int value = random.Next(LoopCount) + 1;
                list.Insert(index, value);
                speedyList.Insert(index, value);
            }
            Assert.AreEqual(LoopCount * 2, list.Count);
            Assert.AreEqual(list.Count, speedyList.Count);

            list.Clear();
            speedyList.Clear();
            for (int i = 0; i < LoopCount; i++)
            {
                int index = random.Next(list.Count);
                int value = random.Next(LoopCount) + 1;
                list.Insert(index, value);
                speedyList.Insert(index, value);
            }
            Assert.AreEqual(LoopCount, list.Count);
            Assert.AreEqual(list.Count, speedyList.Count);
        }