コード例 #1
0
        public void HashSet_Generic_TrimExcess_Repeatedly(int setLength)
        {
            PooledSet <T> set      = (PooledSet <T>)GenericISetFactory(setLength);
            List <T>      expected = set.ToList();

            set.TrimExcess();
            set.TrimExcess();
            set.TrimExcess();
            Assert.True(set.SetEquals(expected));
        }
コード例 #2
0
        public void HashSet_Generic_TrimExcess_AfterClearingAndAddingAllElementsBack(int setLength)
        {
            if (setLength > 0)
            {
                PooledSet <T> set = (PooledSet <T>)GenericISetFactory(setLength);
                set.TrimExcess();
                set.Clear();
                set.TrimExcess();
                Assert.Equal(0, set.Count);

                AddToCollection(set, setLength);
                set.TrimExcess();
                Assert.Equal(setLength, set.Count);
            }
        }
コード例 #3
0
        public void HashSet_Generic_TrimExcess_AfterRemovingOneElement(int setLength)
        {
            if (setLength > 0)
            {
                PooledSet <T> set             = (PooledSet <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));
            }
        }
コード例 #4
0
        public void HashSet_Generic_TrimExcess_OnValidSetThatHasntBeenRemovedFrom(int setLength)
        {
            PooledSet <T> set = (PooledSet <T>)GenericISetFactory(setLength);

            set.TrimExcess();
        }