HashSet class

                                             
    java.lang.Object                                        
     |                                       
     |--java.util.AbstractCollection                                    
         |                                   
         |--java.util.AbstractSet                                
             |                               
             |--java.util.HashSet                            
                                             

This class implements the Set interface, backed by a hash table (actually a HashMap instance).

ConstructorSummary
HashSet()Creates a new, empty set; the backing HashMap instance has default initial capacity (16) and load factor (0.75).
HashSet(Collection<? extends E> c) Creates a new set containing the elements in the specified collection.
HashSet(int initialCapacity)Creates a new, empty set; the backing HashMap instance has the specified initial capacity and default load factor (0.75).
HashSet(int initialCapacity, float loadFactor)Creates a new, empty set; the backing HashMap instance has the specified initial capacity and the specified load factor.

ReturnMethodSummary
booleanadd(E e)Adds the specified element to this set if it is not already present.
voidclear()Removes all of the elements from this set.
Objectclone()Returns a shallow copy of this HashSet instance: the elements themselves are not cloned.
booleancontains(Object o)Returns true if this set contains the specified element.
booleanisEmpty()Returns true if this set contains no elements.
Iterator<E>iterator()Returns an iterator over the elements in this set.
booleanremove(Object o)Removes the specified element from this set if it is present.
intsize()Returns the number of elements in this set (its cardinality).
Revised from Open JDK source code
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.