Пример #1
0
        public void EnsureCapacity_Generic_GrowCapacityWithFreeList(int setLength)
        {
            LinkedHashSet <T> set = (LinkedHashSet <T>)GenericISetFactory(setLength);

            // Remove the first element to ensure we have a free list.
            Assert.True(set.Remove(set.ElementAt(0)));

            int currentCapacity = set.EnsureCapacity(0);

            Assert.True(currentCapacity > 0);

            int newCapacity = set.EnsureCapacity(currentCapacity + 1);

            Assert.True(newCapacity > currentCapacity);
        }
Пример #2
0
        public void LinkedHashSet_Generic_TrimExcess_AfterRemovingOneElement(int setLength)
        {
            if (setLength > 0)
            {
                LinkedHashSet <T> set      = (LinkedHashSet <T>)GenericISetFactory(setLength);
                List <T>          expected = set.ToList();
                T elementToRemove          = set.ElementAt(0);

                set.TrimExcess();
                Assert.True(set.Remove(elementToRemove));
                expected.Remove(elementToRemove);
                set.TrimExcess();

                Assert.True(set.SetEquals(expected));
            }
        }