public class WeakSet<T>
extends java.util.AbstractSet<T>
implements java.io.Serializable, java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
protected java.lang.ref.ReferenceQueue |
queue
The reference queue used to get object removal notifications.
|
protected java.util.Set |
serialized_set |
protected java.util.Set |
set
The set which will be used for element storage.
|
Constructor and Description |
---|
WeakSet()
Construct a WeakSet based on a HashSet.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(java.lang.Object obj)
Add an element to the set.
|
void |
clear()
Removes all of the elements from this set.
|
java.lang.Object |
clone()
Returns a shallow copy of this WeakSet instance: the elements themselves are not cloned.
|
boolean |
contains(java.lang.Object obj)
Returns true if this set contains the specified element.
|
protected void |
expungeStaleEntries()
Remove garbage collected entries.
|
boolean |
isEmpty()
Returns true if this set contains no elements.
|
java.util.Iterator |
iterator()
Return an iteration over the elements in the set.
|
protected java.lang.Object |
readResolve()
Perform special handling on serialization.
|
boolean |
remove(java.lang.Object obj)
Removes the given element from this set if it is present.
|
int |
size()
Return the size of the set.
|
java.lang.Object[] |
toArray()
Convert the set to an array.
|
java.lang.Object[] |
toArray(java.lang.Object[] result)
Convert the set to an array.
|
protected java.lang.Object |
writeReplace()
Perform special handling on serialization.
|
protected transient java.util.Set set
protected transient java.lang.ref.ReferenceQueue queue
protected java.util.Set serialized_set
public int size()
public java.util.Iterator iterator()
public java.lang.Object[] toArray()
public java.lang.Object[] toArray(java.lang.Object[] result)
public boolean add(java.lang.Object obj)
public boolean isEmpty()
public boolean contains(java.lang.Object obj)
contains
in interface java.util.Collection<T>
contains
in interface java.util.Set<T>
contains
in class java.util.AbstractCollection<T>
obj
- Element whose presence in this set is to be tested.public boolean remove(java.lang.Object obj)
public void clear()
public java.lang.Object clone()
clone
in class java.lang.Object
protected final void expungeStaleEntries()
protected java.lang.Object writeReplace() throws java.io.ObjectStreamException
java.io.ObjectStreamException
protected java.lang.Object readResolve() throws java.io.ObjectStreamException
java.io.ObjectStreamException