Example #1
0
        public void TestAddingDuplicatedElements()
        {
            SortedDeque<int> sortedDeque = new SortedDeque<int>();

            List<int> valuesToAdd = new List<int> { 2, 1, 9, 1, 5, 2, 9 };

            for (int i = 0; i < valuesToAdd.Count; ++i)
                sortedDeque.Insert(valuesToAdd[i]);

            valuesToAdd = valuesToAdd.OrderBy(x => x).ToList();

            List<int> uniqueValues = new List<int>(valuesToAdd).Distinct().ToList();

            for (int i = 0; i < uniqueValues.Count; ++i)
            {
                Assert.AreEqual(uniqueValues.ElementAt(i), sortedDeque.At(i));
            }

            Assert.IsFalse(sortedDeque.Empty());
            Assert.AreEqual(valuesToAdd.Count, sortedDeque.SizeTotal);
            Assert.AreEqual(uniqueValues.Count, sortedDeque.SizeUnique);

            Assert.AreEqual(1, sortedDeque.NumberOfBuckets);
        }