public class HashSet extends Object implements Set, Cloneable, Serializable
Modifier and Type | Field and Description |
---|---|
private HashSet |
internalHashSet |
private static long |
serialVersionUID |
Constructor and Description |
---|
HashSet() |
HashSet(Collection c) |
HashSet(int initialCapacity) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(Object o)
Adds an element.
|
boolean |
addAll(Collection c) |
void |
clear() |
Object |
clone() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection c) |
boolean |
equals(Object o) |
int |
hashCode() |
boolean |
isEmpty()
Checks if the collection contains elements.
|
Iterator |
iterator()
Returns an iterator over the elements in this collection.
|
private void |
readObject(ObjectInputStream in) |
boolean |
remove(Object o)
Removes one instance of the specified element.
|
boolean |
removeAll(Collection c) |
int |
size()
Returns the number of elements in this collection.
|
Object[] |
toArray()
Returns an array containing all of the elements in this collection.
|
Object[] |
toArray(Object[] a) |
private void |
writeObject(ObjectOutputStream out) |
private static final long serialVersionUID
private transient HashSet internalHashSet
public HashSet()
public HashSet(Collection c)
public HashSet(int initialCapacity)
public boolean add(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(Object o)
Collection
remove
in interface Collection
o
- the element to be removedpublic int size()
Collection
size
in interface Collection
public Object[] toArray()
Collection
toArray
in interface Collection
public void clear()
public boolean contains(Object o)
private void writeObject(ObjectOutputStream out) throws IOException
IOException
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public boolean addAll(Collection c)
public boolean containsAll(Collection c)
public boolean removeAll(Collection c)