Java record-HashSet under 55-Set

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.