Constructors Summary |
---|
public WeakHashSet()Constructs a new empty WeakHashSet with default values passed the the backing
store.
backingStore = new WeakHashMap();
|
public WeakHashSet(Collection c)Constructs a new WeakHashSet with default values passed the the backing store and
fills it with the given collection. Note that duplicates in the collection will
merely be overwritten
backingStore = new WeakHashMap(Math.max((int)(c.size() / .75f) + 1, 16));
addAll(c);
|
public WeakHashSet(int initialCapacity, float loadFactor)Constructs a new WeakHashSet with the values given passed the the backing store.
backingStore = new WeakHashMap(initialCapacity, loadFactor);
|
public WeakHashSet(int initialCapacity)Constructs a new WeakHashSet with the values given passed the the backing store.
backingStore = new WeakHashMap(initialCapacity);
|
Methods Summary |
---|
public boolean | add(java.lang.Object o){@inheritDoc}
if (o == null) {
throw new NullPointerException();
}
return backingStore.put(o, DUMMY) == null;
|
public boolean | addAll(java.util.Collection c){@inheritDoc}
boolean changed = false;
Iterator iter = c.iterator();
while (iter.hasNext()) {
changed = (changed | (backingStore.put(iter.next(), DUMMY) != DUMMY));
}
return changed;
|
public void | clear(){@inheritDoc}
backingStore.clear();
|
protected java.lang.Object | clone(){@inheritDoc}
throw new CloneNotSupportedException();
|
public boolean | contains(java.lang.Object o){@inheritDoc}
return backingStore.containsKey(o);
|
public boolean | containsAll(java.util.Collection c){@inheritDoc}
return backingStore.keySet()
.containsAll(c);
|
public boolean | equals(java.lang.Object o){@inheritDoc}
return backingStore.equals(o);
|
public int | hashCode()Returns the hash code value for this set.
Gives back the hashCode for the backing store key set. The user should be aware,
however, that this hash code can change without user intervention as the objects
in the collection can easily be collected microseconds after completetion of the
method. It is not reccomended that the user rely on this hash code for
consistency
return backingStore.keySet()
.hashCode();
|
public boolean | isEmpty(){@inheritDoc}
return backingStore.keySet()
.isEmpty();
|
public java.util.Iterator | iterator()Returns an iterator over the elements contained in this collection.
Note that this iterator is extremely volatile because the user may iterate over an
element in the set and find seconds later that it has been removed. This is
because of the semantics of weak references which act like a second thread is
silently modifying the collection. For this reason, it is advisable that if the
user wants to do something with the set that they maintain a strong reference to
the object and not rely on it being in the collection for them.
This iterator is fail fast and WeakReference transparrent. By this we mean that
the iterator simply ignores objects pending in the reference queue for cleanup.
return backingStore.keySet()
.iterator();
|
public boolean | remove(java.lang.Object o){@inheritDoc}
return backingStore.keySet()
.remove(o);
|
public boolean | removeAll(java.util.Collection c){@inheritDoc}
return backingStore.keySet()
.removeAll(c);
|
public boolean | retainAll(java.util.Collection c){@inheritDoc}
return backingStore.keySet()
.retainAll(c);
|
public int | size(){@inheritDoc}
return backingStore.keySet()
.size();
|
public java.lang.Object[] | toArray(){@inheritDoc}
return backingStore.keySet()
.toArray();
|
public java.lang.Object[] | toArray(java.lang.Object[] a){@inheritDoc}
return backingStore.keySet()
.toArray(a);
|
public java.lang.String | toString(){@inheritDoc}
return backingStore.keySet()
.toString();
|