public class HashSet extends java.lang.Object implements Set, java.lang.Cloneable, Serializable
Constructor and Description |
---|
HashSet() |
HashSet(Collection c) |
HashSet(int initialCapacity) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(java.lang.Object o)
Adds an element.
|
boolean |
addAll(Collection c) |
void |
clear() |
java.lang.Object |
clone() |
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(Collection c) |
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
boolean |
isEmpty()
Checks if the collection contains elements.
|
Iterator |
iterator()
Returns an iterator over the elements in this collection.
|
boolean |
remove(java.lang.Object o)
Removes one instance of the specified element.
|
boolean |
removeAll(Collection c) |
int |
size()
Returns the number of elements in this collection.
|
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this collection.
|
java.lang.Object[] |
toArray(java.lang.Object[] a) |
public HashSet()
public HashSet(Collection c)
public HashSet(int initialCapacity)
public boolean add(java.lang.Object o)
Collection
add
in interface Collection
public boolean isEmpty()
Collection
isEmpty
in interface Collection
public Iterator iterator()
Collection
iterator
in interface Collection
public boolean remove(java.lang.Object o)
Collection
remove
in interface Collection
o
- the element to be removedpublic int size()
Collection
size
in interface Collection
public java.lang.Object[] toArray()
Collection
toArray
in interface Collection
public void clear()
public boolean contains(java.lang.Object o)
public java.lang.Object clone()
clone
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public boolean addAll(Collection c)
public boolean containsAll(Collection c)
public boolean removeAll(Collection c)
public java.lang.Object[] toArray(java.lang.Object[] a)