public class WeakSet
extends java.util.AbstractSet
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()
size
in interface java.util.Collection
size
in interface java.util.Set
size
in class java.util.AbstractCollection
public java.util.Iterator iterator()
iterator
in interface java.lang.Iterable
iterator
in interface java.util.Collection
iterator
in interface java.util.Set
iterator
in class java.util.AbstractCollection
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection
toArray
in interface java.util.Set
toArray
in class java.util.AbstractCollection
public java.lang.Object[] toArray(java.lang.Object[] result)
toArray
in interface java.util.Collection
toArray
in interface java.util.Set
toArray
in class java.util.AbstractCollection
public boolean add(java.lang.Object obj)
add
in interface java.util.Collection
add
in interface java.util.Set
add
in class java.util.AbstractCollection
obj
- Element to add to the set.public boolean isEmpty()
isEmpty
in interface java.util.Collection
isEmpty
in interface java.util.Set
isEmpty
in class java.util.AbstractCollection
public boolean contains(java.lang.Object obj)
contains
in interface java.util.Collection
contains
in interface java.util.Set
contains
in class java.util.AbstractCollection
obj
- Element whose presence in this set is to be tested.public boolean remove(java.lang.Object obj)
remove
in interface java.util.Collection
remove
in interface java.util.Set
remove
in class java.util.AbstractCollection
obj
- Object to be removed from this set, if present.public void clear()
clear
in interface java.util.Collection
clear
in interface java.util.Set
clear
in class java.util.AbstractCollection
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