Why can't I preallocate a hashset<T>?
There are times when i might be adding a lot of elements to it and i want to eliminate resizing.
Why can't I preallocate a hashset<T>?
There are times when i might be adding a lot of elements to it and i want to eliminate resizing.
This capability was added in 4.7.2:
HashSet<T>(Int32)
Initializes a new instance of the HashSet<T> class that is empty,
but has reserved space for capacity items and uses the default
equality comparer for the set type.