Source Code : Weak HashSet from objectweb jac
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Weak HashSet from objectweb jac
// Revised from objectweb jac
import java.lang.Cloneable;
import java.util.AbstractSet;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
import java.util.WeakHashMap;
public class WeakHashSet extends AbstractSet
implements Set
{
private transient WeakHashMap map;
public WeakHashSet() {
map = new WeakHashMap();
}
public WeakHashSet(Collection c) {
map = new WeakHashMap(Math.max((int) (c.size()/.75f) + 1, 16));
addAll(c);
}
public WeakHashSet(int initialCapacity, float loadFactor) {
map = new WeakHashMap(initialCapacity, loadFactor);
}
public WeakHashSet(int initialCapacity) {
map = new WeakHashMap(initialCapacity);
}
public Iterator iterator() {
return map.keySet().iterator();
}
public int size() {
return map.size();
}
public boolean isEmpty() {
return map.isEmpty();
}
public boolean contains(Object o) {
return map.containsKey(o);
}
public boolean add(Object o) {
return map.put(o, Boolean.TRUE)==null;
}
public boolean remove(Object o) {
return map.remove(o)==Boolean.TRUE;
}
public void clear() {
map.clear();
}
}
Thank with us