public void HashSet_Generic_TrimExcess_AfterClearingAndAddingAllElementsBack(int setLength) { if (setLength > 0) { SegmentedHashSet <T> set = (SegmentedHashSet <T>)GenericISetFactory(setLength); set.TrimExcess(); set.Clear(); set.TrimExcess(); Assert.Equal(0, set.Count); AddToCollection(set, setLength); set.TrimExcess(); Assert.Equal(setLength, set.Count); } }
/// <inheritdoc cref="ImmutableHashSet{T}.Builder.Clear()"/> public void Clear() { if (ReadOnlySet.Count != 0) { if (_mutableSet is null) { _mutableSet = new SegmentedHashSet <T>(KeyComparer); _set = default; } else { _mutableSet.Clear(); } } }
/// <summary> /// Returns a set of ModifyEnumerable delegates that modify the enumerable passed to them. /// </summary> protected override IEnumerable <ModifyEnumerable> GetModifyEnumerables(ModifyOperation operations) { if ((operations & ModifyOperation.Clear) == ModifyOperation.Clear) { yield return((IEnumerable enumerable) => { SegmentedHashSet <string> casted = ((SegmentedHashSet <string>)enumerable); if (casted.Count > 0) { casted.Clear(); return true; } return false; }); } }