com.iparelan.util
Class WeakHashSet<T>
java.lang.Object
com.iparelan.util.WeakHashSet<T>
- Type Parameters:
T - The type of objects held in the set.
- All Implemented Interfaces:
- Cloneable, Iterable<T>, Collection<T>, Set<T>
@Decorator
@Copyright(value="Copyright © 2008, Iparelan Solutions, LLC. All rights reserved.")
public class WeakHashSet<T>
- extends Object
- implements Set<T>, Cloneable
A type-safe alternative to HashSet that guarantees that
objects in the set are not excluded from garbage collection because they
are elements of the set.
- Version:
- July 2008
- Author:
- Greg Mattes
- See Also:
WeakHashSet,
"Hardcore Java," Simmons, Chapter 11, "A Weak Collection"
delegate
private final Set<T> delegate
WEAKHASHSET_DELEGATE_CLASSNAME
public static final String WEAKHASHSET_DELEGATE_CLASSNAME
- See Also:
- Constant Field Values
WeakHashSet
public WeakHashSet()
- Creates a
WeakHashSet
WeakHashSet
public WeakHashSet(Collection<? extends T> collection)
- Creates a
WeakHashSet
- Parameters:
collection - see HashSet
WeakHashSet
public WeakHashSet(int initialCapacity,
float loadFactor)
- Creates a
WeakHashSet
- Parameters:
initialCapacity - see HashSetloadFactor - see HashSet
WeakHashSet
public WeakHashSet(int initialCapacity)
- Creates a
WeakHashSet
- Parameters:
initialCapacity - see HashSet
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty in interface Collection<T>- Specified by:
isEmpty in interface Set<T>
add
public boolean add(T object)
- Specified by:
add in interface Collection<T>- Specified by:
add in interface Set<T>
addAll
public boolean addAll(Collection<? extends T> collection)
- Specified by:
addAll in interface Collection<T>- Specified by:
addAll in interface Set<T>
clear
public void clear()
- Specified by:
clear in interface Collection<T>- Specified by:
clear in interface Set<T>
contains
public boolean contains(Object object)
- Specified by:
contains in interface Collection<T>- Specified by:
contains in interface Set<T>
containsAll
public boolean containsAll(Collection collection)
- Specified by:
containsAll in interface Collection<T>- Specified by:
containsAll in interface Set<T>
equals
public boolean equals(Object object)
- Specified by:
equals in interface Collection<T>- Specified by:
equals in interface Set<T>- Overrides:
equals in class Object
hashCode
public int hashCode()
- Specified by:
hashCode in interface Collection<T>- Specified by:
hashCode in interface Set<T>- Overrides:
hashCode in class Object
iterator
public Iterator<T> iterator()
- Specified by:
iterator in interface Iterable<T>- Specified by:
iterator in interface Collection<T>- Specified by:
iterator in interface Set<T>
remove
public boolean remove(Object object)
- Specified by:
remove in interface Collection<T>- Specified by:
remove in interface Set<T>
removeAll
public boolean removeAll(Collection collection)
- Specified by:
removeAll in interface Collection<T>- Specified by:
removeAll in interface Set<T>
retainAll
public boolean retainAll(Collection collection)
- Specified by:
retainAll in interface Collection<T>- Specified by:
retainAll in interface Set<T>
size
public int size()
- Specified by:
size in interface Collection<T>- Specified by:
size in interface Set<T>
toArray
public Object[] toArray()
- Specified by:
toArray in interface Collection<T>- Specified by:
toArray in interface Set<T>
toArray
public <T> T[] toArray(T[] array)
- Specified by:
toArray in interface Collection<T>- Specified by:
toArray in interface Set<T>
toString
public String toString()
- Overrides:
toString in class Object
clone
protected WeakHashSet<T> clone()
throws CloneNotSupportedException
- Overrides:
clone in class Object
- Throws:
CloneNotSupportedException
Copyright © 2008 Iparelan Solutions, LLC. All rights reserved.