com.bstek.dorado.util
public class WeakHashSet<E> extends java.lang.Object implements java.util.Set<E>
WeakHashSet的作用类似与WeakHashMap
,它不会阻止被引用的对象被GC回收。
并且WeakHashSet会自动的剔除掉那些已被GC回收的引用,因此WeakHashSet是会自动收缩的。
WeakHashMap
Constructor and Description |
---|
WeakHashSet() |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E o)
Adds the specified element to this set if it is not already present
(optional operation).
|
boolean |
addAll(java.util.Collection<? extends E> c)
Adds all of the elements in the specified collection to this set if
they're not already present (optional operation).
|
void |
clear()
Removes all of the elements from this set (optional operation).
|
boolean |
contains(java.lang.Object o)
Returns true if this set contains the specified element.
|
boolean |
containsAll(java.util.Collection<?> c)
Returns true if this set contains all of the elements of the
specified collection.
|
boolean |
isEmpty()
Returns true if this set contains no elements.
|
java.util.Iterator<E> |
iterator()
Returns an iterator over the elements in this set.
|
boolean |
remove(java.lang.Object o)
Removes the specified element from this set if it is present (optional
operation).
|
boolean |
removeAll(java.util.Collection<?> c)
Removes from this set all of its elements that are contained in the
specified collection (optional operation).
|
boolean |
retainAll(java.util.Collection<?> c)
Retains only the elements in this set that are contained in the specified
collection (optional operation).
|
int |
size()
Returns the number of elements in this set (its cardinality).
|
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this set.
|
<T> T[] |
toArray(T[] a)
Returns an array containing all of the elements in this set; the runtime
type of the returned array is that of the specified array.
|
public int size()
public void clear()
public boolean isEmpty()
public boolean add(E o)
public boolean contains(java.lang.Object o)
public boolean remove(java.lang.Object o)
public boolean addAll(java.util.Collection<? extends E> c)
public boolean containsAll(java.util.Collection<?> c)
public boolean removeAll(java.util.Collection<?> c)
public boolean retainAll(java.util.Collection<?> c)
public java.util.Iterator<E> iterator()
public java.lang.Object[] toArray()
public <T> T[] toArray(T[] a)
toArray
in interface java.util.Collection<E>
toArray
in interface java.util.Set<E>
a
- the array into which the elements of this set are to be stored,
if it is big enough; otherwise, a new array of the same
runtime type is allocated for this purpose.Copyright © 2001-2011 www.BSTEK.com All Rights Reserved.