An unordered hash-table based Set implementation.
The elements of a HashSet
must have consistent equality
and hashCode implementations. This means that the equals operation
must define a stable equivalence relation on the elements (reflexive,
symmetric, transitive, and consistent over time), and that the hashCode
must consistent with equality, so that the same for objects that are
considered equal.
The set allows null
as an element.
Most simple operations on HashSet
are done in (potentially amorteized)
constant time: add, contains, remove, and length, provided the hash
codes of objects are well distributed.