E
- The type of elements in the set.public class WeakHashSet<E> extends AbstractSet<E> implements CheckedCollection<E>
WeakHashSet
will automatically be
removed when it is no longer in ordinary use. More precisely, the presence of an entry will not
prevent the entry from being discarded by the garbage collector, that is, made finalizable,
finalized, and then reclaimed. When an entry has been discarded it is effectively removed from
the set, so this class behaves somewhat differently than other Set
implementations.
If you would like to use WeakHashSet
as inside a factory to prevent creating duplicate
immutable objects, please look at the CanonicalSet
subclass.
The WeakHashSet
class is thread-safe.
WeakHashMap
Constructor and Description |
---|
WeakHashSet()
Deprecated.
Use
WeakHashSet(Class) . |
WeakHashSet(Class<E> type)
Constructs a
WeakHashSet . |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E obj)
Adds the specified element to this set if it is not already present.
|
void |
clear()
Removes all of the elements from this set.
|
boolean |
contains(Object obj)
Returns
true if this set contains the specified element. |
Class<E> |
getElementType()
Returns the element type.
|
Iterator<E> |
iterator()
Returns an iterator over the elements contained in this collection.
|
boolean |
remove(Object obj)
Removes a single instance of the specified element from this set, if it is present
|
int |
size()
Returns the count of element in this set.
|
E[] |
toArray()
Returns a view of this set as an array.
|
equals, hashCode, removeAll
addAll, containsAll, isEmpty, retainAll, toArray, toString
addAll, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray
addAll, containsAll, isEmpty, retainAll, spliterator, toArray
public WeakHashSet()
WeakHashSet(Class)
.WeakHashSet
.public Class<E> getElementType()
getElementType
in interface CheckedCollection<E>
public int size()
size
in interface Collection<E>
size
in interface Set<E>
size
in class AbstractCollection<E>
public boolean contains(Object obj)
true
if this set contains the specified element.contains
in interface Collection<E>
contains
in interface Set<E>
contains
in class AbstractCollection<E>
obj
- Object to be checked for containment in this set.true
if this set contains the specified element.public boolean remove(Object obj)
remove
in interface Collection<E>
remove
in interface Set<E>
remove
in class AbstractCollection<E>
obj
- element to be removed from this set, if present.true
if the set contained the specified element.public boolean add(E obj)
false
.add
in interface Collection<E>
add
in interface Set<E>
add
in class AbstractCollection<E>
obj
- Element to be added to this set.true
if this set did not already contain the specified element.public void clear()
clear
in interface Collection<E>
clear
in interface Set<E>
clear
in class AbstractCollection<E>
public E[] toArray()
toArray
in interface Collection<E>
toArray
in interface Set<E>
toArray
in class AbstractCollection<E>
Copyright © 1996–2019 Geotools. All rights reserved.