Whole document tree
java.util
|
Constructor Summary | |
HashSet()
Constructs a new, empty set; the backing HashMap instance has default capacity and load factor, which is 0.75. |
|
HashSet(Collection c)
Constructs a new set containing the elements in the specified collection. |
|
HashSet(int initialCapacity)
Constructs a new, empty set; the backing HashMap instance has the specified initial capacity and default load factor, which is 0.75. |
|
HashSet(int initialCapacity,
float loadFactor)
Constructs a new, empty set; the backing HashMap instance has the specified initial capacity and the specified load factor. |
Method Summary | |
boolean |
add(Object o)
Adds the specified element to this set if it is not already present. |
void |
clear()
Removes all of the elements from this set. |
Object |
clone()
Returns a shallow copy of this HashSet instance: the elements themselves are not cloned. |
boolean |
contains(Object o)
Returns true if this set contains the specified element. |
boolean |
isEmpty()
Returns true if this set contains no elements. |
Iterator |
iterator()
Returns an iterator over the elements in this set. |
boolean |
remove(Object o)
Removes the given element from this set if it is present. |
int |
size()
Returns the number of elements in this set (its cardinality). |
Methods inherited from class java.util.AbstractSet |
equals, hashCode, removeAll |
Methods inherited from class java.util.AbstractCollection |
addAll, containsAll, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Set |
addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray |
Constructor Detail |
public HashSet()
public HashSet(Collection c)
c
- the collection whose elements are to be placed into this set.public HashSet(int initialCapacity, float loadFactor)
initialCapacity
- the initial capacity of the hash map.loadFactor
- the load factor of the hash map.IllegalArgumentException
- if the initial capacity is less
than zero, or if the load factor is nonpositive.public HashSet(int initialCapacity)
initialCapacity
- the initial capacity of the hash table.IllegalArgumentException
- if the initial capacity is less
than zero.Method Detail |
public Iterator iterator()
iterator
in interface Set
iterator
in class AbstractCollection
ConcurrentModificationException
public int size()
size
in interface Set
size
in class AbstractCollection
public boolean isEmpty()
isEmpty
in interface Set
isEmpty
in class AbstractCollection
public boolean contains(Object o)
contains
in interface Set
contains
in class AbstractCollection
o
- element whose presence in this set is to be tested.public boolean add(Object o)
add
in interface Set
add
in class AbstractCollection
o
- element to be added to this set.public boolean remove(Object o)
remove
in interface Set
remove
in class AbstractCollection
o
- object to be removed from this set, if present.public void clear()
clear
in interface Set
clear
in class AbstractCollection
java.util.Set
UnsupportedOperationException
- if the clear method
is not supported by this set.public Object clone()
|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2001 Sun Microsystems, Inc. 901 San Antonio Road
Palo Alto, California, 94303, U.S.A. All Rights Reserved.