org.openorb.util
Class WeakHashSet

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractSet
              |
              +--org.openorb.util.WeakHashSet
All Implemented Interfaces:
java.util.Collection, java.util.Set

public class WeakHashSet
extends java.util.AbstractSet
implements java.util.Set

A weak set. This does not prevent it's members being reclaimed by the garbage collector.

Version:
$Revision: 1.6 $ $Date: 2002/06/28 08:59:06 $
Author:
Chris Wood

Constructor Summary
WeakHashSet()
          Constructs a new, empty set; the backing WeakHashMap instance has default capacity and load factor, which is 0.75.
WeakHashSet(java.util.Collection c)
          Constructs a new set containing the elements in the specified collection.
WeakHashSet(int initialCapacity)
          Constructs a new, empty set; the backing WeakHashMap instance has the specified initial capacity and default load factor, which is 0.75.
WeakHashSet(int initialCapacity, float loadFactor)
          Constructs a new, empty set; the backing WeakHashMap instance has the specified initial capacity and the specified load factor.
 
Method Summary
 boolean add(java.lang.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.
 boolean contains(java.lang.Object o)
          Returns true if this set contains the specified element.
 boolean isEmpty()
          Returns true if this set contains no elements.
 java.util.Iterator iterator()
          Returns an iterator over the elements in this set.
 boolean remove(java.lang.Object o)
          Removes the given element from this set if it is present.
 int size()
          Returns the number of elements in this set.
 
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
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
 

Constructor Detail

WeakHashSet

public WeakHashSet()
Constructs a new, empty set; the backing WeakHashMap instance has default capacity and load factor, which is 0.75.

WeakHashSet

public WeakHashSet(java.util.Collection c)
Constructs a new set containing the elements in the specified collection. The capacity of the backing WeakHashMap instance is twice the size of the specified collection or eleven (whichever is greater), and the default load factor (which is 0.75) is used.
Parameters:
c - the collection whose elements are to be placed into this set.

WeakHashSet

public WeakHashSet(int initialCapacity,
                   float loadFactor)
Constructs a new, empty set; the backing WeakHashMap 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.

WeakHashSet

public WeakHashSet(int initialCapacity)
Constructs a new, empty set; the backing WeakHashMap instance has the specified initial capacity and default load factor, which is 0.75.
Parameters:
initialCapacity - the initial capacity of the hash table.
Method Detail

iterator

public java.util.Iterator iterator()
Returns an iterator over the elements in this set. The elements are returned in no particular order.
Specified by:
iterator in interface java.util.Set
Overrides:
iterator in class java.util.AbstractCollection
Returns:
an Iterator over the elements in this set.

size

public int size()
Returns the number of elements in this set. Unlike most set implementations this operation takes linear time in the size of the set.
Specified by:
size in interface java.util.Set
Overrides:
size in class java.util.AbstractCollection
Returns:
the number of elements in this set (its cardinality).

isEmpty

public boolean isEmpty()
Returns true if this set contains no elements. Unlike most set implementations this operation takes linear time in the size of the set.
Specified by:
isEmpty in interface java.util.Set
Overrides:
isEmpty in class java.util.AbstractCollection
Returns:
true if this set contains no elements.

contains

public boolean contains(java.lang.Object o)
Returns true if this set contains the specified element.
Specified by:
contains in interface java.util.Set
Overrides:
contains in class java.util.AbstractCollection
Parameters:
o - element whose presence in this set is to be tested.
Returns:
true if this set contains the specified element.

add

public boolean add(java.lang.Object o)
Adds the specified element to this set if it is not already present.
Specified by:
add in interface java.util.Set
Overrides:
add in class java.util.AbstractCollection
Parameters:
o - element to be added to this set.
Returns:
true if the set did not already contain the specified element.

remove

public boolean remove(java.lang.Object o)
Removes the given element from this set if it is present.
Specified by:
remove in interface java.util.Set
Overrides:
remove in class java.util.AbstractCollection
Parameters:
o - object to be removed from this set, if present.
Returns:
true if the set contained the specified element.

clear

public void clear()
Removes all of the elements from this set.
Specified by:
clear in interface java.util.Set
Overrides:
clear in class java.util.AbstractCollection