Beispiel #1
0
        public void RemoveRangeByRank()
        {
            for (var _ = 0; _ < 100; _++)
            {
                var list = new SortSet <int, int>();
                for (var i = 0; i < 10; i++)
                {
                    list.Add(i, i);
                }

                list.RemoveRangeByRank(3, 8);
                Assert.AreEqual(0, list.GetElementByRank(0));
                Assert.AreEqual(1, list.GetElementByRank(1));
                Assert.AreEqual(2, list.GetElementByRank(2));
                Assert.AreEqual(9, list.GetElementByRank(3));
                for (var i = 3; i < 9; i++)
                {
                    list.Add(i, i);
                }
                list.Add(33, 3);
                list.RemoveRangeByRank(3, 3);
                Assert.AreEqual(0, list.GetElementByRank(0));
                Assert.AreEqual(1, list.GetElementByRank(1));
                Assert.AreEqual(2, list.GetElementByRank(2));
                var r = list.GetElementByRank(3);
                Assert.AreEqual(true, r == 3 || r == 33);
            }
        }