API Overview API Index Package Overview Direct link to this page
JDK 1.6
  java.util. HashSet View Source
Author(s)
Josh Bloch
Neal Gafter
Since
1.2
Version
1.37, 04/21/06
Serial
Hierarchy
 Object
      AbstractCollection
          AbstractSet
              HashSet
Implements
 Set
 Cloneable
 Serializable
Subclasses
Description
public class HashSet
  This class implements the Set interface, backed by a hash table (actually a HashMap instance).
See also:    Collection Set TreeSet HashMap
Constructors
public HashSet ()
Constructs a new, empty set; the backing HashMap instance has default initial capacity (16) and load factor (0.75).
public HashSet (Collection<Object> c)
  Constructs a new set containing the elements in the specified collection.
public HashSet (int initialCapacity)
  Constructs a new, empty set; the backing HashMap instance has the specified initial capacity and default load factor (0.75).
public HashSet (int initialCapacity, float loadFactor)
  Constructs a new, empty set; the backing HashMap instance has the specified initial capacity and the specified load factor.
pack-private HashSet (int initialCapacity, float loadFactor, boolean dummy)
  Constructs a new, empty linked hash set.
Methods
Hide/Show inherited methods
public boolean add ( E e) [Overrides AbstractCollection] [Specified in Set]
  Adds the specified element to this set if it is not already present.
public boolean addAll (Collection<Object> c) [Inherited From AbstractCollection]
  Adds all of the elements in the specified collection to this collection (optional operation).
public void clear () [Overrides AbstractCollection] [Specified in Set]
  Removes all of the elements from this set.
public Object clone ()
  Returns a shallow copy of this HashSet instance: the elements themselves are not cloned.
public boolean contains (Object o) [Overrides AbstractCollection] [Specified in Set]
  Returns true if this set contains the specified element.
public boolean containsAll (Collection<Object> c) [Inherited From AbstractCollection]
  Returns true if this collection contains all of the elements in the specified collection.
public boolean equals (Object o) [Inherited From AbstractSet]
  Compares the specified object with this set for equality.
public int hashCode () [Inherited From AbstractSet]
  Returns the hash code value for this set.
public boolean isEmpty () [Overrides AbstractCollection] [Specified in Set]
  Returns true if this set contains no elements.
public Iterator< E> iterator () [Specified in Set]
  Returns an iterator over the elements in this set.
public boolean remove (Object o) [Overrides AbstractCollection] [Specified in Set]
  Removes the specified element from this set if it is present.
public boolean removeAll (Collection<Object> c) [Inherited From AbstractSet]
  Removes from this set all of its elements that are contained in the specified collection (optional operation).
public boolean retainAll (Collection<Object> c) [Inherited From AbstractCollection]
  Retains only the elements in this collection that are contained in the specified collection (optional operation).
public int size () [Specified in Set]
  Returns the number of elements in this set (its cardinality).
public Object toArray () [Inherited From AbstractCollection]
  Returns an array containing all of the elements in this collection.
public T toArray ( T a) [Inherited From AbstractCollection]
  Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
public String toString () [Inherited From AbstractCollection]
  Returns a string representation of this collection.
Fields
Hide/Show inherited fields
pack-privatefinalstatic long serialVersionUID = "-5024744406713321676"
Nested Classes
Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar