|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.unboundid.util.WeakHashSet<T>
T
- The type of element held in this set.public final class WeakHashSet<T>
This class provides a weak hash set, which maintains weak references to the
elements it contains, so that they will be removed automatically once there
are no more normal references to them.
Note that because this set uses weak references, elements may disappear from
the set at any time without being explicitly removed. This means that care
must be taken to ensure that the result of one method must not be considered
authoritative for subsequent calls to the same method or other methods in
this class.
Constructor Summary | |
---|---|
WeakHashSet()
Creates a new weak hash set with the default initial capacity. |
|
WeakHashSet(int initialCapacity)
Creates a new weak hash set with the specified initial capacity. |
Method Summary | ||
---|---|---|
boolean |
add(T e)
Adds the provided element to this set, if it does not already exist. |
|
boolean |
addAll(java.util.Collection<? extends T> c)
Adds any elements from the provided collection to this set if they were not already present. |
|
T |
addAndGet(T e)
Adds the provided element to the set if it does not already exist, and retrieves the value stored in the set. |
|
void |
clear()
Clears the contents of this set. |
|
boolean |
contains(java.lang.Object e)
Indicates whether this set contains the specified element. |
|
boolean |
containsAll(java.util.Collection<?> c)
Indicates whether this set currently contains all of the elements in the provided collection. |
|
boolean |
equals(java.lang.Object o)
Indicates whether the provided object is equal to this set. |
|
T |
get(T e)
Retrieves the existing instance of the provided element from this set. |
|
int |
hashCode()
Retrieves a hash code for this set. |
|
boolean |
isEmpty()
Indicates whether this set is currently empty. |
|
java.util.Iterator<T> |
iterator()
Retrieves an iterator across all elements in this set. |
|
boolean |
remove(java.lang.Object e)
Removes the specified element from this set, if it exists. |
|
boolean |
removeAll(java.util.Collection<?> c)
Removes all of the elements of the provided collection from this set. |
|
boolean |
retainAll(java.util.Collection<?> c)
Removes all elements from this set which are not contained in the provided collection. |
|
int |
size()
Retrieves the number of elements currently held in this set. |
|
java.lang.Object[] |
toArray()
Retrieves an array containing all of the elements currently held in this set. |
|
|
toArray(E[] a)
Retrieves an array containing all of the elements currently held in this set. |
|
java.lang.String |
toString()
Retrieves a string representation of this set. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public WeakHashSet()
public WeakHashSet(int initialCapacity)
initialCapacity
- The initial capacity for this weak hash set. It
must not be null
.Method Detail |
---|
public void clear()
clear
in interface java.util.Collection<T>
clear
in interface java.util.Set<T>
public boolean isEmpty()
isEmpty
in interface java.util.Collection<T>
isEmpty
in interface java.util.Set<T>
true
if this set is empty, or false
if not.public int size()
size
in interface java.util.Collection<T>
size
in interface java.util.Set<T>
public boolean contains(java.lang.Object e)
contains
in interface java.util.Collection<T>
contains
in interface java.util.Set<T>
e
- The element for which to make the determination.
true
if this set contains the specified element, or
false
if not.public boolean containsAll(java.util.Collection<?> c)
containsAll
in interface java.util.Collection<T>
containsAll
in interface java.util.Set<T>
c
- The collection for which to make the determination.
true
if this set currently contains all of the elements in
the provided collection, or false
if not.public T get(T e)
e
- The object for which to obtain the existing element.
null
if
the provided element is not contained in this set.public boolean add(T e)
add
in interface java.util.Collection<T>
add
in interface java.util.Set<T>
e
- The element to be added to the set if it does not already exist.
true
if the element was added to the set (because it was
not already present), or false
if the element was not
added (because it was already in the set).public boolean addAll(java.util.Collection<? extends T> c)
addAll
in interface java.util.Collection<T>
addAll
in interface java.util.Set<T>
c
- The collection containing elements to add.
true
if at least one of the elements was not already in
the set and was added, or false
if no elements were added
because they were already all present.public T addAndGet(T e)
e
- The element to be added to the set if it does not already exist.
public boolean remove(java.lang.Object e)
remove
in interface java.util.Collection<T>
remove
in interface java.util.Set<T>
e
- The element to be removed from this set.
true
if the element existed in the set and was removed, or
false
if not.public boolean removeAll(java.util.Collection<?> c)
removeAll
in interface java.util.Collection<T>
removeAll
in interface java.util.Set<T>
c
- The collection containing the elements to remove from this set.
true
if at least one of the elements from the provided
collection were contained in and therefore removed from the set,
or false
if none of the elements in the given collection
were contained in this set.public boolean retainAll(java.util.Collection<?> c)
retainAll
in interface java.util.Collection<T>
retainAll
in interface java.util.Set<T>
c
- The collection of elements to be retained.
true
if this set contained at least one element not in the
provided collection that was therefore removed, or false
if this set did not have any elements that were not in the
provided collection.public java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T>
iterator
in interface java.util.Collection<T>
iterator
in interface java.util.Set<T>
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection<T>
toArray
in interface java.util.Set<T>
public <E> E[] toArray(E[] a)
toArray
in interface java.util.Collection<T>
toArray
in interface java.util.Set<T>
E
- The type of element for the given array.a
- An array into which the elements will be added if there is
sufficient space.
null
element depicting
the end of the set elements if the given array is larger than this
set), or a newly-allocated array if the provided array was not
large enough.public int hashCode()
hashCode
in interface java.util.Collection<T>
hashCode
in interface java.util.Set<T>
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in interface java.util.Collection<T>
equals
in interface java.util.Set<T>
equals
in class java.lang.Object
o
- The object for which to make the determination.
true
if the provided object is a non-null
set with
the same elements as this set, or false
if not.public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |