Java record-HashSet under 55-Set
Public interface Set <E> extends Collection <E> a collection that does not contain duplicate elements. More specifically, set does not contain e1 and e2 elements that meet e1.equals (e2), and contains at most one null element. As its name implies, this interface imitates the set abstraction in mathematics. Public class HashSet <E> extends AbstractSet <E> implements Set <E>, Cloneable, and Serializable implement the Set interface, which is supported by the hash table (actually a HashMap instance. It does not guarantee the set iteration sequence; in particular, it does not ensure that the sequence remains unchanged. This class allows the use of null elements. This class provides stable performance for basic operations, including add, remove, contains, and size, assuming that the hash function correctly distributes these elements in the bucket. The time required for iteration on this set is the "capacity" and proportion of the size (number of elements) of the HashSet instance and the number of underlying HashMap instances (number of buckets. Therefore, if iteration performance is important, do not set the initial capacity too high (or set the loading factor too low ). The constructor HashSet () constructs a new empty set. The default initial capacity of the underlying HashMap instance is 16, and the load factor is 0.75. HashSet (Collection <? Extends E> c) to construct a new set containing the elements in the specified collection. HashSet (int initialCapacity) constructs a new empty set. Its underlying HashMap instance has the specified initial capacity and default loading Factor (0.75 ). HashSet (int initialCapacity, float loadFactor) constructs a new empty set. Its underlying HashMap instance has the specified initial capacity and the specified loading factor.