|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractCollection
java.util.HashSet
public class HashSet
An implementation of Set that offers constant time retrieval and amortized constant time insertion. This implementation requires that the objects in it have a valid implementation of hashCode. The implementation should return an integer in the range of tagged integers: (2^29) to 2^29 - 1. The implementation that is inherited from Object is not suitable! Strings and Integers have a suitable implementation. This HashSet is based on a HashMap.
| Constructor Summary | |
|---|---|
HashSet()
|
|
HashSet(int initialCapacity)
|
|
| Method Summary | |
|---|---|
boolean |
add(Object o)
If the specified element is not contained within this collection, and addition of this element succeeds, then true will be returned. |
void |
clear()
Removes all the elements in this collection. |
boolean |
contains(Object o)
Searches this Collection for the specified object. |
Iterator |
iterator()
Answers an Iterator on the elements of this Collection. |
boolean |
remove(Object o)
Removes the first occurrence of the specified object from this Collection. |
boolean |
removeAll(Collection other)
Removes all occurrences in this Collection of each object in the specified Collection. |
int |
size()
Answers the number of elements in this Collection. |
Object[] |
toArray()
Answers a new array containing all elements contained in this Collection. |
| Methods inherited from class java.util.AbstractCollection |
|---|
addAll, containsAll, isEmpty, retainAll, toArray, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, println |
| Methods inherited from interface java.util.Set |
|---|
containsAll |
| Methods inherited from interface java.util.Collection |
|---|
addAll, equals, hashCode, isEmpty, retainAll, toArray |
| Constructor Detail |
|---|
public HashSet()
public HashSet(int initialCapacity)
| Method Detail |
|---|
public boolean add(Object o)
AbstractCollection
add in interface Collectionadd in interface Setadd in class AbstractCollectiono - the element to be added.
public boolean remove(Object o)
AbstractCollection
remove in interface Collectionremove in interface Setremove in class AbstractCollectiono - the object to remove
public boolean removeAll(Collection other)
AbstractCollection
removeAll in interface CollectionremoveAll in class AbstractCollectionother - the Collection of objects to remove
public boolean contains(Object o)
AbstractCollection
contains in interface Collectioncontains in interface Setcontains in class AbstractCollectiono - the object to search for
object is an element of this Collection,
false otherwisepublic Iterator iterator()
AbstractCollection
iterator in interface Iterableiterator in interface Collectioniterator in interface Setiterator in class AbstractCollectionIteratorpublic Object[] toArray()
AbstractCollection
toArray in interface CollectiontoArray in interface SettoArray in class AbstractCollectionpublic int size()
AbstractCollection
size in interface Collectionsize in class AbstractCollectionpublic void clear()
AbstractCollection
clear in interface Collectionclear in interface Setclear in class AbstractCollectionCollection.isEmpty(),
Collection.size()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||