| java.lang.Object | |||
| ↳ | java.util.AbstractCollection<E> | ||
| ↳ | java.util.AbstractSet<E> | ||
| ↳ | java.util.HashSet<E> | ||
Known Direct Subclasses
|
HashSet is an implementation of a Set. All optional operations (adding and removing) are supported. The elements can be any objects.
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
Constructs a new empty instance of
HashSet.
|
||||||||||
|
|
Constructs a new instance of
HashSet with the specified capacity.
|
||||||||||
|
|
Constructs a new instance of
HashSet with the specified capacity and load factor.
|
||||||||||
|
|
Constructs a new instance of
HashSet containing the unique elements in the specified collection.
|
||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
Adds the specified object to this
HashSet if not already present.
|
||||||||||
|
|
Removes all elements from this
HashSet, leaving it empty.
|
||||||||||
|
|
Returns a new
HashSet with the same elements and size as this
HashSet.
|
||||||||||
|
|
Searches this
HashSet for the specified object.
|
||||||||||
|
|
Returns true if this
HashSet has no elements, false otherwise.
|
||||||||||
|
|
Returns an Iterator on the elements of this
HashSet.
|
||||||||||
|
|
Removes the specified object from this
HashSet.
|
||||||||||
|
|
Returns the number of elements in this
HashSet.
|
||||||||||
| [Expand]
Inherited Methods
|
|||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class java.util.AbstractSet
|
|||||||||||
From class java.util.AbstractCollection
|
|||||||||||
From class java.lang.Object
|
|||||||||||
From interface java.lang.Iterable
|
|||||||||||
From interface java.util.Collection
|
|||||||||||
From interface java.util.Set
|
|||||||||||
Constructs a new instance of HashSet with the specified capacity.
| capacity | the initial capacity of this HashSet. |
|---|
Constructs a new instance of HashSet with the specified capacity and load factor.
| capacity | the initial capacity. |
|---|---|
| loadFactor | the initial load factor. |
Constructs a new instance of HashSet containing the unique elements in the specified collection.
| collection | the collection of elements to add. |
|---|
Adds the specified object to this HashSet if not already present.
| object | the object to add. |
|---|
true when this HashSet did not already contain the object, false otherwise Returns a new HashSet with the same elements and size as this HashSet.
HashSet.Searches this HashSet for the specified object.
| object | the object to search for. |
|---|
true if object is an element of this HashSet, false otherwise. Returns true if this HashSet has no elements, false otherwise.
true if this HashSet has no elements, false otherwise.Returns an Iterator on the elements of this HashSet.
HashSet.Removes the specified object from this HashSet.
| object | the object to remove. |
|---|
true if the object was removed, false otherwise. Returns the number of elements in this HashSet.
HashSet.