| java.lang.Object | |||
| ↳ | java.util.AbstractCollection<E> | ||
| ↳ | java.util.AbstractSet<E> | ||
| ↳ | java.util.HashSet<E> | ||
|
|
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 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||||
|
| |||||||||||
|
| |||||||||||
|
| |||||||||||
|
| |||||||||||
|
| |||||||||||
Constructs a new instance of HashSet with the specified capacity.
| Parameters | |
|---|---|
capacity |
int:
the initial capacity of this HashSet.
|
Constructs a new instance of HashSet with the specified capacity
and load factor.
| Parameters | |
|---|---|
capacity |
int:
the initial capacity. |
loadFactor |
float:
the initial load factor.
|
Constructs a new instance of HashSet containing the unique
elements in the specified collection.
| Parameters | |
|---|---|
collection |
Collection:
the collection of elements to add.
|
Adds the specified object to this HashSet if not already present.
| Parameters | |
|---|---|
object |
E:
the object to add. |
| Returns | |
|---|---|
boolean |
true when this HashSet did not already contain
the object, false otherwise
|
Searches this HashSet for the specified object.
| Parameters | |
|---|---|
object |
Object:
the object to search for. |
| Returns | |
|---|---|
boolean |
true if object is an element of this
HashSet, false otherwise.
|
Returns true if this HashSet has no elements, false otherwise.
| Returns | |
|---|---|
boolean |
true if this HashSet has no elements,
false otherwise. |
See also:
Removes the specified object from this HashSet.
| Parameters | |
|---|---|
object |
Object:
the object to remove. |
| Returns | |
|---|---|
boolean |
true if the object was removed, false otherwise.
|
Returns the number of elements in this HashSet.
| Returns | |
|---|---|
int |
the number of elements in this HashSet.
|