public void EnsureCapacity_Generic_GrowCapacityWithFreeList(int setLength)
        {
            SegmentedHashSet <T> set = (SegmentedHashSet <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);
        }
        public void HashSet_Generic_TrimExcess_AfterRemovingOneElement(int setLength)
        {
            if (setLength > 0)
            {
                SegmentedHashSet <T> set      = (SegmentedHashSet <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));
            }
        }