public boolean isEmpty() { processQueue(); return map.isEmpty(); }
public int size() { processQueue(); return map.size(); }
public boolean contains(Object o) { processQueue(); Integer key = new Integer(o.hashCode()); boolean contains = map.containsKey(key); return contains; }
public boolean remove(Object o) { processQueue(); Integer key = new Integer(o.hashCode()); return map.remove(key) != null; }
public boolean containsAll(Collection c) { processQueue(); Iterator iter = c.iterator(); boolean contains = true; while( iter.hasNext() ) { Object value = iter.next(); Integer key = new Integer(value.hashCode()); contains &= map.containsKey(key); } return contains; }
public Object[] toArray() { processQueue(); return toArray(new Object[0]); }
public boolean removeAll(Collection c) { processQueue(); Iterator iter = c.iterator(); boolean removed = false; while( iter.hasNext() ) { Object value = iter.next(); removed |= remove(value); } return removed; }
public Iterator iterator() { processQueue(); Iterator theIter = map.values().iterator(); return new ComparableSoftReferenceIterator(theIter); }
public boolean add(Object o) { processQueue(); Integer key = new Integer(o.hashCode()); ComparableSoftReference sr = new ComparableSoftReference(key, o, gcqueue); return map.put(key, sr) == null; }
public boolean addAll(Collection c) { processQueue(); Iterator iter = c.iterator(); boolean added = false; while( iter.hasNext() ) { Object value = iter.next(); Integer key = new Integer(value.hashCode()); ComparableSoftReference sr = new ComparableSoftReference(key, value, gcqueue); added |= map.put(key, sr) == null; } return added; }
public Object[] toArray(Object[] a) { processQueue(); int size = map.size(); Object[] array = {}; if( a.length >= size ) array = a; Iterator iter = map.values().iterator(); int index = 0; while( iter.hasNext() ) { ComparableSoftReference csr = (ComparableSoftReference) iter.next(); Object value = csr.get(); // Create the correct array type if( array.length == 0 ) { if( value == null ) { index ++; continue; } Array.newInstance(value.getClass(), size); } array[index] = value; index ++; } return array; }