Package jadex.collection
Class WeakSet<T>
java.lang.Object
java.util.AbstractCollection<T>
java.util.AbstractSet<T>
jadex.collection.WeakSet<T>
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<T>
,Collection<T>
,Set<T>
A weak set for entries that will be automatically removed when
no references to them are existing any more.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ReferenceQueue
The reference queue used to get object removal notifications.protected Set
protected Set
The set which will be used for element storage. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Add an element to the set.void
clear()
Removes all of the elements from this set.clone()
Returns a shallow copy of this WeakSet instance: the elements themselves are not cloned.boolean
Returns true if this set contains the specified element.protected final void
Remove garbage collected entries.boolean
isEmpty()
Returns true if this set contains no elements.iterator()
Return an iteration over the elements in the set.protected Object
Perform special handling on serialization.boolean
Removes the given element from this set if it is present.int
size()
Return the size of the set.Object[]
toArray()
Convert the set to an array.Object[]
Convert the set to an array.protected Object
Perform special handling on serialization.Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Set
addAll, containsAll, retainAll, spliterator
-
Field Details
-
set
The set which will be used for element storage. -
queue
The reference queue used to get object removal notifications. -
serialized_set
-
-
Constructor Details
-
WeakSet
public WeakSet()Construct a WeakSet based on a HashSet.
-
-
Method Details
-
size
public int size()Return the size of the set.- Specified by:
size
in interfaceCollection<T>
- Specified by:
size
in interfaceSet<T>
- Specified by:
size
in classAbstractCollection<T>
- Returns:
- The size of the set.
-
iterator
Return an iteration over the elements in the set. -
toArray
Convert the set to an array.- Specified by:
toArray
in interfaceCollection<T>
- Specified by:
toArray
in interfaceSet<T>
- Overrides:
toArray
in classAbstractCollection<T>
-
toArray
Convert the set to an array.- Specified by:
toArray
in interfaceCollection<T>
- Specified by:
toArray
in interfaceSet<T>
- Overrides:
toArray
in classAbstractCollection<T>
-
add
Add an element to the set.- Specified by:
add
in interfaceCollection<T>
- Specified by:
add
in interfaceSet<T>
- Overrides:
add
in classAbstractCollection<T>
- Parameters:
obj
- Element to add to the set.- Returns:
- True if the element was added.
-
isEmpty
public boolean isEmpty()Returns true if this set contains no elements.- Specified by:
isEmpty
in interfaceCollection<T>
- Specified by:
isEmpty
in interfaceSet<T>
- Overrides:
isEmpty
in classAbstractCollection<T>
- Returns:
- true if this set contains no elements.
-
contains
Returns true if this set contains the specified element.- Specified by:
contains
in interfaceCollection<T>
- Specified by:
contains
in interfaceSet<T>
- Overrides:
contains
in classAbstractCollection<T>
- Parameters:
obj
- Element whose presence in this set is to be tested.- Returns:
- true if this set contains the specified element.
-
remove
Removes the given element from this set if it is present.- Specified by:
remove
in interfaceCollection<T>
- Specified by:
remove
in interfaceSet<T>
- Overrides:
remove
in classAbstractCollection<T>
- Parameters:
obj
- 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 interfaceCollection<T>
- Specified by:
clear
in interfaceSet<T>
- Overrides:
clear
in classAbstractCollection<T>
-
clone
Returns a shallow copy of this WeakSet instance: the elements themselves are not cloned. -
expungeStaleEntries
protected final void expungeStaleEntries()Remove garbage collected entries. -
writeReplace
Perform special handling on serialization.- Throws:
ObjectStreamException
-
readResolve
Perform special handling on serialization.- Throws:
ObjectStreamException
-