java.util

Class HashSet<E>

Implemented Interfaces:
Cloneable, Collection<E>, Iterable<T>, Serializable, Set<E>
Known Direct Subclasses:
JobStateReasons, LinkedHashSet<E>

public class HashSet<E>
extends AbstractSet<E>
implements Set<E>, Cloneable, Serializable

This class implements the Set interface, backed by a hash table (actually a HashMap instance). It makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time. This class permits the null element.

This class offers constant time performance for the basic operations (add, remove, contains and size), assuming the hash function disperses the elements properly among the buckets. Iterating over this set requires time proportional to the sum of the HashSet instance's size (the number of elements) plus the "capacity" of the backing HashMap instance (the number of buckets). Thus, it's very important not to set the initial capacity too high (or the load factor too low) if iteration performance is important.

Note that this implementation is not synchronized. If multiple threads access a set concurrently, and at least one of the threads modifies the set, it must be synchronized externally. This is typically accomplished by synchronizing on some object that naturally encapsulates the set. If no such object exists, the set should be "wrapped" using the Collections.synchronizedSet method. This is best done at creation time, to prevent accidental unsynchronized access to the HashSet instance:

     Set s = Collections.synchronizedSet(new HashSet(...));
 

The iterators returned by this class's iterator method are fail-fast: if the set is modified at any time after the iterator is created, in any way except through the iterator's own remove method, the Iterator throws a ConcurrentModificationException. Thus, in the face of concurrent modification, the iterator fails quickly and cleanly, rather than risking arbitrary, non-deterministic behavior at an undetermined time in the future.

Note that the fail-fast behavior of an iterator cannot be guaranteed as it is, generally speaking, impossible to make any hard guarantees in the presence of unsynchronized concurrent modification. Fail-fast iterators throw ConcurrentModificationException on a best-effort basis. Therefore, it would be wrong to write a program that depended on this exception for its correctness: the fail-fast behavior of iterators should be used only to detect bugs.

This class is a member of the ../../../guide/collections/index.html"> Java Collections Framework.

Since:
1.2
See Also:
Collection, Set, TreeSet, Collections.synchronizedSet(Set), HashMap, Serialized Form

Constructor Summary

HashSet()
Constructs a new, empty set; the backing HashMap instance has default initial capacity (16) and load factor (0.75).
HashSet(E> 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(E 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 specified 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<E>

equals, hashCode, removeAll

Methods inherited from class java.util.AbstractCollection<E>

T[] toArray, add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toString

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

HashSet

public HashSet()
Constructs a new, empty set; the backing HashMap instance has default initial capacity (16) and load factor (0.75).
Usages and Demos :

View More Examples of HashSet()
   1:     LazySet(Broker broker, String statementID, ConnectionContext contextParms) {
   2:         super(broker, statementID, contextParms, new HashSet());
   3:     }
   4: }

View Full Code Here
   1:     Set s = Collections.synchronizedSet(
   2:       new HashSet());
   3:     Map m = Collections.synchronizedMap(
   4:       new HashMap());
   5:   }

View Full Code Here
   1:   public static void main(String[] args) {
   2:     testVisual(new HashSet());
   3:     testVisual(new TreeSet());
   4:   }

View Full Code Here
   1:         assertTrue(CollectionUtils.isEmpty(new HashMap()));
   2:         assertTrue(CollectionUtils.isEmpty(new HashSet()));
   3: 
   4:         List list = new ArrayList();
   5:         list.add(new Object());

View Full Code Here
   1:   public static void main(String[] args) {
   2:     test(new HashSet());
   3:     test(new TreeSet());
   4:   }

View Full Code Here

HashSet

public HashSet(E> c)
Constructs a new set containing the elements in the specified collection. The HashMap is created with default load factor (0.75) and an initial capacity sufficient to contain the elements in the specified collection.
Parameters:
c - the collection whose elements are to be placed into this set.
Throws:
NullPointerException - if the specified collection is null.
Usages and Demos :

View More Examples of HashSet(E> c)
   1:                 procurement.setNotes(notesTextArea.getText());
   2:                 procurement.setItems(new HashSet(((ItemTableModel)itemsTable.getModel()).getItems()));
   3: 
   4:                 SessionFactory sessionFactory = Persistence.getSessionFactory();
   5:                 Session session = null;

View Full Code Here
   1:         String value = preferences.getString(ICoreConstants.IMPLICIT_DEPENDENCIES);
   2:         fElements = new HashSet((4/3) * tokens.countTokens() + 1);
   3:         while (tokens.hasMoreElements()) {
   4:         ...
   5:         
   6:         Set currentPlugins = new HashSet((4/3) * fElements.size() + 1);
   7:         Iterator it = fElements.iterator();
   8:         ...
   9:         IPluginModelBase[] models = fPage.getCurrentModels();
  10:         Set result = new HashSet((4/3) * models.length + 1);
  11:         for (int i = 0; i < models.length; i++) {

View Full Code Here
   1:         ITargetPlugin[] plugins = getImplicitPluginsInfo().getPlugins();
   2:         Set currentPlugins = new HashSet((4/3) * plugins.length + 1);
   3:         for (int i = 0; i < plugins.length; i++) {
   4:         ...
   5:         IPluginModelBase[] models = PluginRegistry.getActiveModels(false);
   6:         Set result = new HashSet((4/3) * models.length + 1);
   7:         for (int i = 0; i < models.length; i++) {
   8:             BundleDescription desc = models[i].getBundleDescription();
   9:             if (desc != null) {

View Full Code Here
   1:         if (pc1 instanceof PropertyConstraint.Enumeration && pc2 instanceof PropertyConstraint.Enumeration) {
   2:             Set intersection = new HashSet(((PropertyConstraint.Enumeration) pc1).getValues());
   3:             intersection.retainAll(((PropertyConstraint.Enumeration) pc2).getValues());
   4:             if (intersection.size() == 0) {
   5:                 return PropertyConstraint.NONE;

View Full Code Here
   1:         if (header == null)
   2:             return new HashSet(0);
   3:         Set plugins = (header instanceof RequireBundleHeader) ? findManifestPlugins((RequireBundleHeader)header, ignorePkgs):
   4:         ...
   5:         RequireBundleObject[] bundles = header.getRequiredBundles();
   6:         Set result = new HashSet((4/3) * (bundles.length) + 2);
   7:         ArrayList plugins = new ArrayList();
   8:         ...
   9:         BundleSpecification[] bundles = fBase.getBundleDescription().getRequiredBundles();
  10:         Set result = new HashSet((4/3) * (bundles.length) + 2);
  11:         ArrayList plugins = new ArrayList();

View Full Code Here

HashSet

public 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.
Parameters:
initialCapacity - the initial capacity of the hash table.
Throws:
IllegalArgumentException - if the initial capacity is less than zero.
Usages and Demos :

View More Examples of HashSet(int initialCapacity)
   1:                 procurement.setNotes(notesTextArea.getText());
   2:                 procurement.setItems(new HashSet(((ItemTableModel)itemsTable.getModel()).getItems()));
   3: 
   4:                 SessionFactory sessionFactory = Persistence.getSessionFactory();
   5:                 Session session = null;

View Full Code Here
   1:         String value = preferences.getString(ICoreConstants.IMPLICIT_DEPENDENCIES);
   2:         fElements = new HashSet((4/3) * tokens.countTokens() + 1);
   3:         while (tokens.hasMoreElements()) {
   4:         ...
   5:         
   6:         Set currentPlugins = new HashSet((4/3) * fElements.size() + 1);
   7:         Iterator it = fElements.iterator();
   8:         ...
   9:         IPluginModelBase[] models = fPage.getCurrentModels();
  10:         Set result = new HashSet((4/3) * models.length + 1);
  11:         for (int i = 0; i < models.length; i++) {

View Full Code Here
   1:         ITargetPlugin[] plugins = getImplicitPluginsInfo().getPlugins();
   2:         Set currentPlugins = new HashSet((4/3) * plugins.length + 1);
   3:         for (int i = 0; i < plugins.length; i++) {
   4:         ...
   5:         IPluginModelBase[] models = PluginRegistry.getActiveModels(false);
   6:         Set result = new HashSet((4/3) * models.length + 1);
   7:         for (int i = 0; i < models.length; i++) {
   8:             BundleDescription desc = models[i].getBundleDescription();
   9:             if (desc != null) {

View Full Code Here
   1:         if (pc1 instanceof PropertyConstraint.Enumeration && pc2 instanceof PropertyConstraint.Enumeration) {
   2:             Set intersection = new HashSet(((PropertyConstraint.Enumeration) pc1).getValues());
   3:             intersection.retainAll(((PropertyConstraint.Enumeration) pc2).getValues());
   4:             if (intersection.size() == 0) {
   5:                 return PropertyConstraint.NONE;

View Full Code Here
   1:         if (header == null)
   2:             return new HashSet(0);
   3:         Set plugins = (header instanceof RequireBundleHeader) ? findManifestPlugins((RequireBundleHeader)header, ignorePkgs):
   4:         ...
   5:         RequireBundleObject[] bundles = header.getRequiredBundles();
   6:         Set result = new HashSet((4/3) * (bundles.length) + 2);
   7:         ArrayList plugins = new ArrayList();
   8:         ...
   9:         BundleSpecification[] bundles = fBase.getBundleDescription().getRequiredBundles();
  10:         Set result = new HashSet((4/3) * (bundles.length) + 2);
  11:         ArrayList plugins = new ArrayList();

View Full Code Here

HashSet

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.
Parameters:
initialCapacity - the initial capacity of the hash map.
loadFactor - the load factor of the hash map.
Throws:
IllegalArgumentException - if the initial capacity is less than zero, or if the load factor is nonpositive.
Usages and Demos :

View More Examples of HashSet(int initialCapacity,float loadFactor)
   1:     {
   2:         ids = new HashSet(data.getMax("Image.Annotated.ids",2));
   3:         q = new PojosFindAnnotationsQueryDefinition(
   4:         ...
   5:     {
   6:         ids = new HashSet(data.getMax("Dataset.Annotated.ids",2));
   7:         q = new PojosFindAnnotationsQueryDefinition(
   8:                 new Parameters()
   9:                 .addIds(ids) 

View Full Code Here
   1:         inner = e;
   2:         foundClasses = new HashSet(30, 0.8f);
   3:         findMethodReferences(methods, foundClasses);
   4:         findFieldReferences(fields, foundClasses);
   5:         findClassReferences(foundClasses);

View Full Code Here
   1: 
   2:     private final static Set VTL_KEYWORDS = new HashSet(11, 1);
   3: 
   4:     static
   5:     {

View Full Code Here

Method Details

add

public boolean add(E o)
Adds the specified element to this set if it is not already present.
Specified by:
add in interface Set<E>
add in interface Collection<E>
Overrides:
add in interface AbstractCollection<E>
Parameters:
o - element to be added to this set.
Returns:
true if the set did not already contain the specified element.
Usages and Demos :

View More Examples of add(E o)
   1: 
   2: import java.util.HashSet;
   3: import java.util.Iterator;
   4:         ...
   5:     
   6:     private static final HashSet dontSpace = new HashSet();
   7:     static {
   8:         ...
   9:         dontSpace.add(".");
  10:         ...
  11:         dontSpace.add("+");

View Full Code Here
   1: 
   2:         HashSet lines = new HashSet();
   3: 
   4:         ...
   5:                 Object injected = instantiation.getInjected()[j];
   6:                 lines.add("  '" + instantiated.getClass().getName() + "' -> '" + injected.getClass().getName() + "';\n");
   7:             }
   8:         ...
   9: 
  10:     private String sortLines(HashSet lines) {
  11:         ArrayList list = new ArrayList(lines);
  12:         ...
  13:                 if (injected.getClass() != injectedType) {
  14:                     lines.add("  '" + instantiated.getClass().getName() + "' -> '" + injectedType.getName() + "' [style=dotted,label='needs'];\n");

View Full Code Here
   1: 
   2: import java.util.HashSet;
   3: import java.util.Hashtable;
   4:         ...
   5:         fStateSetVector = new Vector();
   6:         fStateSetVector.add(stateSet);
   7:         fVDistance = -1;
   8:         ...
   9:                 StateSet nextStateSet = new StateSet();
  10:                 fStateSetVector.add(nextStateSet);
  11:         ...
  12:                 HashSet emptyProdHT = new HashSet();

View Full Code Here
   1: 
   2: import java.util.HashSet;
   3: import java.util.Iterator;
   4:         ...
   5: 
   6:     private static final HashSet DONT_SPACE_TOKENS = new HashSet();
   7:     static {
   8:         ...
   9:         DONT_SPACE_TOKENS.add(".");
  10:         ...
  11:         DONT_SPACE_TOKENS.add("+");

View Full Code Here
   1: import java.util.HashMap;
   2: import java.util.HashSet;
   3: import java.util.Iterator;
   4:         ...
   5:         
   6:     private static final HashSet dontSpace = new HashSet();
   7:     static {
   8:         ...
   9:         dontSpace.add(".");
  10:         ...
  11:         dontSpace.add("+");

View Full Code Here

clear

public void clear()
Removes all of the elements from this set.
Specified by:
clear in interface Set<E>
clear in interface Collection<E>
Overrides:
clear in interface AbstractCollection<E>
Usages and Demos :

View More Examples of clear()
   1: public class TracersBase {
   2:                 HashSet tracers;
   3:                 
   4:         ...
   5:                 public TracersBase() {
   6:                         tracers = new HashSet() ;            
   7:                 } 
   8:         ...
   9:                 public void reset() {
  10:                         tracers.clear();
  11:                 } 

View Full Code Here
   1: import java.awt.image.*;
   2: import com.sun.java.util.collections.HashSet;
   3: import java.util.*;
   4:         ...
   5:   long [] positions;
   6:   private HashSet selected = new HashSet(5);
   7:   Hashtable highlighted;
   8:         ...
   9:     positions = new long[initialSize];
  10:     selected.clear();
  11:     highlighted = new Hashtable();

View Full Code Here
   1: import java.io.IOException;
   2: import java.util.HashSet;
   3: 
   4:         ...
   5: 
   6:     private HashSet _queryAnswers;
   7: 
   8:         ...
   9:         _listener = l;
  10:         _queryAnswers = new HashSet();
  11:     }
  12:         ...
  13:     public void clear() {
  14:         _queryAnswers.clear();

View Full Code Here
   1: import java.lang.ref.SoftReference;
   2: import java.util.HashSet;
   3: import java.util.WeakHashMap;
   4:         ...
   5: 
   6:     private HashSet locks = new HashSet();
   7: 
   8:         ...
   9:     {
  10:         locks.clear();
  11:     }

View Full Code Here
   1: import java.util.HashMap;
   2: import java.util.HashSet;
   3: 
   4:         ...
   5: {
   6:   private HashSet pseudoPages;
   7:   private HashMap pageStyles;
   8:         ...
   9:     this.pageStyles = new HashMap();
  10:     this.pseudoPages = new HashSet();
  11:   }
  12:         ...
  13:   {
  14:     pseudoPages.clear();

View Full Code Here

clone

public Object clone()
Returns a shallow copy of this HashSet instance: the elements themselves are not cloned.
Overrides:
clone in interface Object
Returns:
a shallow copy of this set.
Usages and Demos :

View More Examples of clone()
   1:    
   2:    Map<AppEventType, HashSet<AppEventListener>> listeners = new HashMap<AppEventType, HashSet<AppEventListener>>();
   3:    
   4:         ...
   5:       {
   6:          listeners.put(evtType, new HashSet<AppEventListener>());
   7:       }
   8:         ...
   9:          HashSet set = listeners.get(evtType);
  10:          Set targets = (Set) set.clone();
  11:          AppEvent evt = new AppEvent(_source, evtType, target);

View Full Code Here
   1: 
   2: import java.util.HashSet;
   3: import java.util.Iterator;
   4:         ...
   5:                 
   6:                 HashSet oldReferences = new HashSet(projectReferences.length);
   7:                 for (int i = 0; i < projectReferences.length; i++){
   8:         ...
   9:                 }
  10:                 HashSet newReferences = (HashSet)oldReferences.clone();
  11:         

View Full Code Here
   1: import java.util.HashMap;
   2: import java.util.HashSet;
   3: import java.util.Iterator;
   4:         ...
   5:   private HashMap declarations;
   6:   private HashSet importantDeclarations;
   7:   private transient StyleKey[] declaredKeys;
   8:         ...
   9:     this.declarations = new HashMap();
  10:     this.importantDeclarations = new HashSet();
  11:   }
  12:         ...
  13:     }
  14:     return (StyleKey[]) declaredKeys.clone();

View Full Code Here
   1: import java.util.HashMap;
   2: import java.util.HashSet;
   3: import java.util.Iterator;
   4:         ...
   5:     private DataStructure _data;
   6:     private HashSet _pendingPeers;
   7:     private HashMap _pendingPeerTimes;
   8:         ...
   9:     private HashSet _successfulPeers;
  10:     private HashSet _successfulExploratoryPeers;
  11:         ...
  12:         synchronized (_pendingPeers) {
  13:             return (Set)_pendingPeers.clone(); 

View Full Code Here
   1: import java.util.HashMap;
   2: import java.util.HashSet;
   3: import java.util.Iterator;
   4:         ...
   5:     private RouterContext _context;
   6:     private HashSet _pendingPeers;
   7:     private HashMap _pendingPeerTimes;
   8:         ...
   9:     private HashSet _attemptedPeers;
  10:     private HashSet _failedPeers;
  11:         ...
  12:         synchronized (_pendingPeers) {
  13:             return (Set)_pendingPeers.clone();

View Full Code Here

contains

public boolean contains(Object o)
Returns true if this set contains the specified element.
Specified by:
contains in interface Set<E>
contains in interface Collection<E>
Overrides:
contains in interface AbstractCollection<E>
Parameters:
o - element whose presence in this set is to be tested.
Returns:
true if this set contains the specified element.
Usages and Demos :

View More Examples of contains(Object o)
   1: import java.io.Serializable;
   2: import java.util.HashSet;
   3: import java.util.Iterator;
   4:         ...
   5:     private final String nodeName;
   6:     private final HashSet isInstanceNodeNames = new HashSet();
   7: 
   8:         ...
   9:         if ( object instanceof Element ) {
  10:             return isInstanceNodeNames.contains( ( ( Element ) object ).getName() );
  11:         }

View Full Code Here
   1: import org.w3c.dom.Element;
   2: import java.util.HashSet;
   3: import java.util.StringTokenizer;
   4:         ...
   5: 
   6:     private static final HashSet urlAttributes;
   7: 
   8:         ...
   9:     static {
  10:         urlAttributes = new HashSet(URL_ATTRIBUTES.length);
  11:         for (int idx = 0; idx < URL_ATTRIBUTES.length; idx++) {
  12:         ...
  13:                                                String attrName) {
  14:         return urlAttributes.contains(attrName);

View Full Code Here
   1: 
   2: import java.util.HashSet;
   3: import java.util.StringTokenizer;
   4:         ...
   5: 
   6:     private static final HashSet urlAttributes;
   7:     
   8:         ...
   9:     static {
  10:         urlAttributes = new HashSet(URL_ATTRIBUTES.length);
  11:         for (int idx = 0; idx < URL_ATTRIBUTES.length; idx++) {
  12:         ...
  13:                                   String attrName) {
  14:         return urlAttributes.contains(attrName);

View Full Code Here
   1: import java.io.Serializable;
   2: import java.util.HashSet;
   3: import java.util.Iterator;
   4:         ...
   5:   private int index;
   6:   private HashSet inEdges = null;
   7: 
   8:         ...
   9:   private HashSet outEdges = null;
  10: 
  11:         ...
  12:   public boolean hasOut(OPT_GraphNode x) {
  13:     return  outEdges!=null && outEdges.contains(x);

View Full Code Here
   1: import org.enhydra.wireless.wml.dom.WMLDocument;
   2: import java.util.HashSet;
   3: import org.enhydra.apache.xerces.dom.DocumentTypeImpl;
   4:         ...
   5: 
   6:     private static final HashSet urlAttributes;
   7: 
   8:         ...
   9:     static {
  10:         urlAttributes = new HashSet(URL_ATTRIBUTES.length);
  11:         for (int idx = 0; idx < URL_ATTRIBUTES.length; idx++) {
  12:         ...
  13:                                   String attrName) {
  14:         return urlAttributes.contains(attrName);

View Full Code Here

isEmpty

public boolean isEmpty()
Returns true if this set contains no elements.
Specified by:
isEmpty in interface Set<E>
isEmpty in interface Collection<E>
Overrides:
isEmpty in interface AbstractCollection<E>
Returns:
true if this set contains no elements.
Usages and Demos :

View More Examples of isEmpty()
   1: 
   2: import java.util.HashSet;
   3: 
   4:         ...
   5: 
   6:     private final HashSet dialectScopes;
   7: 
   8:         ...
   9:     protected AbstractAuxiliaryDatabaseObject() {
  10:         this.dialectScopes = new HashSet();
  11:     }
  12:         ...
  13:     public boolean appliesToDialect(Dialect dialect) {
  14:         return dialectScopes.isEmpty() || dialectScopes.contains( dialect.getClass().getName() );

View Full Code Here
   1: 
   2: import java.util.HashSet;
   3: import java.util.Iterator;
   4:         ...
   5:     String roleDesc;
   6:     HashSet users;
   7: 
   8:         ...
   9:         this.roleDesc = roleDesc;
  10:         users = new HashSet();
  11:     }
  12:         ...
  13:     public boolean hasUsers(){
  14:         return !users.isEmpty();

View Full Code Here
   1: 
   2: import java.util.HashSet;
   3: import java.util.Hashtable;
   4:         ...
   5: 
   6:     protected HashSet data = new HashSet();
   7: 
   8:         ...
   9:     public boolean isEmpty() {
  10:         return data.isEmpty();
  11:     }

View Full Code Here
   1: 
   2: import java.util.HashSet;
   3: import java.util.Iterator;
   4:         ...
   5: public class CombinationFileFilter extends FileFilter {
   6:     private HashSet filterList;
   7:     private SimpleFileFilter preferedFileFilter;
   8:         ...
   9:         setDescription(description);
  10:         filterList = new HashSet();
  11: 
  12:         ...
  13:         if (!contains(ff)) {
  14:             if (filterList.isEmpty()) {

View Full Code Here
   1: 
   2: import java.util.HashSet;
   3: import java.util.Iterator;
   4:         ...
   5:     
   6:     private HashSet includes = new HashSet();
   7:     private HashSet excludes = new HashSet();
   8:         ...
   9:     public boolean isEmpty() {
  10:         return (includes.isEmpty() && excludes.isEmpty());
  11:     }

View Full Code Here

iterator

public Iterator iterator()
Returns an iterator over the elements in this set. The elements are returned in no particular order.
Specified by:
iterator in interface Set<E>
iterator in interface Collection<E>
iterator in interface Iterable<T>
Overrides:
iterator in interface AbstractCollection<E>
Returns:
an Iterator over the elements in this set.
Usages and Demos :

View More Examples of iterator()
   1: 
   2: import java.util.HashSet;
   3: import java.util.Iterator;
   4:         ...
   5: 
   6:     private HashSet set = new HashSet();
   7:     
   8:         ...
   9:     public Iterator iterator() {
  10:         return set.iterator();
  11:     }

View Full Code Here
   1: package net.betterjava.design.collection.shadowcopy;
   2: import java.util.HashSet;
   3: import java.util.Iterator;
   4:         ...
   5: public class RegisterHashSet implements Cloneable {
   6:     private HashSet visitors;
   7: 
   8:         ...
   9:     public RegisterHashSet() {
  10:         visitors = new HashSet();
  11:     }
  12:         ...
  13:     public void amendFirstAddress(String newAddress) {
  14:         Iterator it = visitors.iterator();

View Full Code Here
   1: 
   2: import java.util.HashSet;
   3: import java.util.Iterator;
   4:         ...
   5:     String roleDesc;
   6:     HashSet users;
   7: 
   8:         ...
   9:         this.roleDesc = roleDesc;
  10:         users = new HashSet();
  11:     }
  12:         ...
  13:     public Iterator users(){
  14:         return users.iterator();

View Full Code Here
   1: 
   2: import java.util.HashSet;
   3: import java.util.Iterator;
   4:         ...
   5:     private String passWord;
   6:     private HashSet roles;
   7: 
   8:         ...
   9:         this.passWord = passWord;
  10:         roles = new HashSet();
  11:     }
  12:         ...
  13:     public Iterator roles(){
  14:         return roles.iterator();

View Full Code Here
   1: 
   2: import java.util.HashSet;
   3: import java.util.Iterator;
   4:         ...
   5:   public static void serialize(SerializationStreamWriter streamWriter,
   6:       HashSet instance) throws SerializationException {
   7:     int size = instance.size();
   8:         ...
   9: 
  10:     Iterator iter = instance.iterator();
  11:     while (iter.hasNext()) {
  12:         ...
  13:   public static void deserialize(SerializationStreamReader streamReader,
  14:       HashSet instance) throws SerializationException {

View Full Code Here

remove

public boolean remove(Object o)
Removes the specified element from this set if it is present.
Specified by:
remove in interface Set<E>
remove in interface Collection<E>
Overrides:
remove in interface AbstractCollection<E>
Parameters:
o - object to be removed from this set, if present.
Returns:
true if the set contained the specified element.
Usages and Demos :

View More Examples of remove(Object o)
   1: import java.util.HashMap;
   2: import java.util.HashSet;
   3: import java.util.Set;
   4:         ...
   5:     if (getAttributes().size() > 0) {
   6:       HashSet attrs = new HashSet(getAttributes());
   7:         ...
   8:       attrs.remove("copy");
   9:       if (attrs.size() > 0) {
  10:         ...
  11:     if (hasAttribute(key)) {
  12:       d_attributes.remove(key);

View Full Code Here
   1: import java.util.Arrays;
   2: import java.util.HashSet;
   3: import java.util.HashMap;
   4:         ...
   5:     
   6:     private HashSet receivingApps = null;
   7:     
   8:         ...
   9:     private HashSet sendingApps = null;
  10:     
  11:         ...
  12:     public boolean removeReceivingApp(String app) {
  13:         return receivingApps != null && receivingApps.remove(app);

View Full Code Here
   1: import java.util.HashMap;
   2: import java.util.HashSet;
   3: import java.util.Iterator;
   4:         ...
   5:         Enumeration enumPropertiesNames = properties.propertyNames(  );
   6:         HashSet listXmlPageName = new HashSet(  );
   7:         
   8:         ...
   9:         
  10:         listXmlPageName.remove( PROPERTY_GROUP_RESERVED_KEY );
  11:         

View Full Code Here
   1: import java.util.ArrayList;
   2: import java.util.HashSet;
   3: import java.util.Set;
   4:         ...
   5:         FileObject folder = createScratchFolder();
   6:         HashSet names = new HashSet();
   7: 
   8:         ...
   9:         folder.resolveFile("dir1").delete(Selectors.SELECT_ALL);
  10:         names.remove("dir1");
  11:         assertSameFileSet(names, folder.getChildren());
  12:         ...
  13:         folder.resolveFile("file1.html").delete(Selectors.SELECT_ALL);
  14:         names.remove("file1.html");

View Full Code Here
   1: import java.util.HashMap;
   2: import java.util.HashSet;
   3: import java.util.Iterator;
   4:         ...
   5:     public Iterator sectionIterator() {
   6:         HashSet nondefaultSessions = new HashSet(sections.keySet());
   7:         ...
   8:         nondefaultSessions.remove(DEFAULT_SESSION_ID);
   9:         return nondefaultSessions.iterator();
  10:         ...
  11:     public void removeSetting(SessionID sessionID, String key) {
  12:         getOrCreateSessionProperties(sessionID).remove(key);

View Full Code Here

size

public int size()
Returns the number of elements in this set (its cardinality).
Specified by:
size in interface Set<E>
size in interface Collection<E>
Overrides:
size in interface AbstractCollection<E>
Returns:
the number of elements in this set (its cardinality).
Usages and Demos :

View More Examples of size()
   1: 
   2: import java.util.HashSet;
   3: 
   4:         ...
   5: public class GenActions {
   6:   private HashSet actions;
   7: 
   8:         ...
   9:   public GenActions() {
  10:     actions = new HashSet();
  11:   }
  12:         ...
  13:   public String []getActions() {
  14:     String []temp = new String[actions.size()];

View Full Code Here
   1: 
   2: import java.util.HashSet;
   3: 
   4:         ...
   5: public class GenActions {
   6:   private HashSet actions;
   7: 
   8:         ...
   9:   public GenActions() {
  10:     actions = new HashSet();
  11:   }
  12:         ...
  13:   public String []getActions() {
  14:     String []temp = new String[actions.size()];

View Full Code Here
   1: public class TracersBase {
   2:                 HashSet tracers;
   3:                 
   4:         ...
   5:                 public TracersBase() {
   6:                         tracers = new HashSet() ;            
   7:                 } 
   8:         ...
   9:                 public int size() {
  10:                         return tracers.size();
  11:                 }

View Full Code Here
   1: 
   2: import java.util.HashSet;
   3: 
   4:         ...
   5:     private Object writer;
   6:     private final HashSet readers = new HashSet();
   7: 
   8:         ...
   9:     public synchronized int getSharedCount() {
  10:         return readers.size();
  11:     }

View Full Code Here
   1: import java.io.Serializable;
   2: import java.util.HashSet;
   3: 
   4:         ...
   5:   private YAWLTask triggeringTask;
   6:   private HashSet  setMembers;
   7:   
   8:         ...
   9:       this.triggeringTask = null;
  10:       setMembers = new HashSet();
  11:   }
  12:         ...
  13:   public int size() {
  14:     return setMembers.size();

View Full Code Here