Package jadex.commons.collection
Class WeakSet<T>
- java.lang.Object
- 
- java.util.AbstractCollection<E>
- 
- java.util.AbstractSet<T>
- 
- jadex.commons.collection.WeakSet<T>
 
 
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- java.lang.Cloneable,- java.lang.Iterable<T>,- java.util.Collection<T>,- java.util.Set<T>
 
 public class WeakSet<T> extends java.util.AbstractSet<T> implements java.io.Serializable, java.lang.CloneableA weak set for entries that will be automatically removed when no references to them are existing any more.- See Also:
- Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.lang.ref.ReferenceQueuequeueThe reference queue used to get object removal notifications.protected java.util.Setserialized_setprotected java.util.SetsetThe set which will be used for element storage.
 - 
Constructor SummaryConstructors Constructor Description WeakSet()Construct a WeakSet based on a HashSet.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(java.lang.Object obj)Add an element to the set.voidclear()Removes all of the elements from this set.java.lang.Objectclone()Returns a shallow copy of this WeakSet instance: the elements themselves are not cloned.booleancontains(java.lang.Object obj)Returns true if this set contains the specified element.protected voidexpungeStaleEntries()Remove garbage collected entries.booleanisEmpty()Returns true if this set contains no elements.java.util.Iteratoriterator()Return an iteration over the elements in the set.protected java.lang.ObjectreadResolve()Perform special handling on serialization.booleanremove(java.lang.Object obj)Removes the given element from this set if it is present.intsize()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.ObjectwriteReplace()Perform special handling on serialization.
 
- 
- 
- 
Method Detail- 
sizepublic int size() Return the size of the set.
 - 
iteratorpublic java.util.Iterator iterator() Return an iteration over the elements in the set.
 - 
toArraypublic java.lang.Object[] toArray() Convert the set to an array.
 - 
toArraypublic java.lang.Object[] toArray(java.lang.Object[] result) Convert the set to an array.
 - 
addpublic boolean add(java.lang.Object obj) Add an element to the set.
 - 
isEmptypublic boolean isEmpty() Returns true if this set contains no elements.
 - 
containspublic boolean contains(java.lang.Object obj) Returns true if this set contains the specified element.- Specified by:
- containsin interface- java.util.Collection<T>
- Specified by:
- containsin interface- java.util.Set<T>
- Overrides:
- containsin class- java.util.AbstractCollection<T>
- Parameters:
- obj- Element whose presence in this set is to be tested.
- Returns:
- true if this set contains the specified element.
 
 - 
removepublic boolean remove(java.lang.Object obj) Removes the given element from this set if it is present.
 - 
clearpublic void clear() Removes all of the elements from this set.
 - 
clonepublic java.lang.Object clone() Returns a shallow copy of this WeakSet instance: the elements themselves are not cloned.- Overrides:
- clonein class- java.lang.Object
- Returns:
- A shallow copy of this set.
 
 - 
expungeStaleEntriesprotected final void expungeStaleEntries() Remove garbage collected entries.
 - 
writeReplaceprotected java.lang.Object writeReplace() throws java.io.ObjectStreamExceptionPerform special handling on serialization.- Throws:
- java.io.ObjectStreamException
 
 - 
readResolveprotected java.lang.Object readResolve() throws java.io.ObjectStreamExceptionPerform special handling on serialization.- Throws:
- java.io.ObjectStreamException
 
 
- 
 
-