Foley .NET Utilities Class Library

HashSet Constructor (ICollection, Int32, Single, IHashCodeProvider, IComparer)

Initializes a new instance of the HashSet class that contains elements copied from the specified collection with the specified initial capacity and using the specified load factor, the specified hash code provider and the specified comparer.

[Visual Basic]
Overloads Public Sub New( _
   ByVal collection As ICollection, _
   ByVal initialCapacity As Integer, _
   ByVal loadFactor As Single, _
   ByVal hcp As IHashCodeProvider, _
   ByVal comparer As IComparer _
)
[C#]
public HashSet(
   ICollection collection,
   int initialCapacity,
   float loadFactor,
   IHashCodeProvider hcp,
   IComparer comparer
);

Parameters

collection
The ICollection whose elements are copied to the new list.
initialCapacity
The approximate number of elements that the HashSet can initially contain.
loadFactor
A number in the range from 0.1 through 1.0 indicating the maximum ratio of elements to buckets.
hcp
The IHashCodeProvider that supplies the hash codes for all elements in the HashSet.

-or-

A null reference (Nothing in Visual Basic) to use the default hash code provider, which is each element's implementation of GetHashCode.
comparer
The IComparer to use to determine whether two elements are equal.

-or-

A null reference (Nothing in Visual Basic) to use the default comparer, which is each element's implementation of Equals.

Exceptions

Exception TypeCondition
System.ArgumentOutOfRangeExceptioncapacity is less than zero.

-or-

loadFactor is less than 0.1.

-or-

loadFactor is greater than 1.0.

See Also

HashSet Class | HashSet Members | Foley.Utilities.Collections Namespace | HashSet Constructor Overload List