public void HashSet_Generic_TrimExcess_Repeatedly(int setLength)
        {
            SegmentedHashSet <T> set      = (SegmentedHashSet <T>)GenericISetFactory(setLength);
            List <T>             expected = set.ToList();

            set.TrimExcess();
            set.TrimExcess();
            set.TrimExcess();
            Assert.True(set.SetEquals(expected));
        }
        public void HashSet_Generic_Constructor_HashSet_SparselyFilled(int count)
        {
            SegmentedHashSet <T> source         = (SegmentedHashSet <T>)CreateEnumerable(EnumerableType.SegmentedHashSet, null, count, 0, 0);
            List <T>             sourceElements = source.ToList();

            foreach (int i in NonSquares(count))
            {
                source.Remove(sourceElements[i]);// Unevenly spaced survivors increases chance of catching any spacing-related bugs.
            }
            SegmentedHashSet <T> set = new SegmentedHashSet <T>(source, GetIEqualityComparer());

            Assert.True(set.SetEquals(source));
        }
        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));
            }
        }