UnorderedBag - Description


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

When creating a set UnorderedBag<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 UnorderedBag - Comparer may be used to manually specify the comparer.

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

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

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