예제 #1
0
        public void CouldRandomlyAddRemoveFirst()
        {
            var map   = new SortedChunkedMap <int, int>(50);
            var list  = new List <int>();
            var count = 10000;

            for (int i = 0; i < count; i++)
            {
                list.Add(i);
            }
            Shuffle(list);
            for (int i = 0; i < count; i++)
            {
                map.Add(list[i], list[i]);
                Assert.AreEqual(i + 1, map.Version);
            }

            for (int i = 0; i < count; i++)
            {
                KeyValuePair <int, int> tmp;
                Assert.True(map.RemoveFirst(out tmp));
                Assert.AreEqual(i + count + 1, map.Version);
            }
            Assert.True(map.IsEmpty);
        }
예제 #2
0
        public void CouldRemoveFirst() {
            var scm = new SortedChunkedMap<int, int>(50);
            for (int i = 0; i < 100; i++) {
                scm.Add(i, i);
            }

            scm.Remove(50);
            Assert.AreEqual(50, scm.outerMap.Last.Key);

            KeyValuePair<int, int> kvp;
            scm.RemoveFirst(out kvp);
            Assert.AreEqual(0, kvp.Value);
            Assert.AreEqual(1, scm.First.Value);
            Assert.AreEqual(0, scm.outerMap.First.Key);
        }
예제 #3
0
        public void RemoveFirstLastIncrementsVersion()
        {
            var map = new SortedChunkedMap <long, long>();

            map.Add(1, 1);
            Assert.AreEqual(1, map.Version);
            map.Add(2, 2);
            Assert.AreEqual(2, map.Version);
            KeyValuePair <long, long> tmp;

            map.RemoveFirst(out tmp);
            Assert.AreEqual(3, map.Version);
            map.RemoveLast(out tmp);
            Assert.AreEqual(4, map.Version);
        }
예제 #4
0
        public void CouldRemoveFirst()
        {
            var scm = new SortedChunkedMap <int, int>();

            for (int i = 0; i < 10000; i++)
            {
                scm.Add(i, i);
            }
            KeyValuePair <int, int> result;
            var removed = scm.RemoveFirst(out result);

            Assert.IsTrue(removed);
            Assert.IsTrue(!scm.IsEmpty);
            Assert.IsTrue(scm.Count == 9999);
            Assert.IsTrue(scm.First.Key == 1);
        }
예제 #5
0
        public void CouldRemoveFirst()
        {
            var scm = new SortedChunkedMap <int, int>(50);

            for (int i = 0; i < 100; i++)
            {
                scm.Add(i, i);
            }

            scm.Remove(50);
            Assert.AreEqual(50, scm.outerMap.Last.Key);

            KeyValuePair <int, int> kvp;

            scm.RemoveFirst(out kvp);
            Assert.AreEqual(0, kvp.Value);
            Assert.AreEqual(1, scm.First.Value);
            Assert.AreEqual(0, scm.outerMap.First.Key);
        }
예제 #6
0
 public void CouldRemoveFirst() {
     var scm = new SortedChunkedMap<int, int>();
     for (int i = 0; i < 10000; i++) {
         scm.Add(i, i);
     }
     KeyValuePair<int, int> result;
     var removed = scm.RemoveFirst(out result);
     Assert.IsTrue(removed);
     Assert.IsTrue(!scm.IsEmpty);
     Assert.IsTrue(scm.Count == 9999);
     Assert.IsTrue(scm.First.Key == 1);
 }