HashSet - Description


The generic class HashSet is an unordered set of entries. The generic has a single type parameter, T - the data type of the set. The generic class HashSet exists in the namespace Calculus (in assembly Calculus.dll).

When creating a set HashSet<T>, the key class T is expected to be equality comparable. There are two ways the equality comparer may be specified:

  1. the class T may derive from IEqualityComparable of T or
  2. the constructor HashSet - Comparer may be used to manually specify the comparer.

The declaration of the hash class (in C#) is shown below.

[Serializable]
public class HashSet<T> : ISet<T>,
                          IEquatable<HashSet<T>>

When foreach is applied to a set, the entries are presented in the order of the hash codes for elements.