/** * Return the size of the set. * * @return The size of the set. */ public int size() { maintain(); return set.size(); }
/** * Returns <tt>true</tt> if this set contains no elements. * * @return <tt>true</tt> if this set contains no elements. */ public boolean isEmpty() { maintain(); return set.isEmpty(); }
/** * Returns a shallow copy of this <tt>WeakSet</tt> instance: the elements * themselves are not cloned. * * @return A shallow copy of this set. */ public Object clone() { maintain(); try { return super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(); } } }
/** * Add an element to the set. * * @param obj Element to add to the set. * @return True if the element was added. */ public boolean add(final Object obj) { maintain(); return set.add(WeakObject.create(obj, queue)); }
/** * Returns <tt>true</tt> if this set contains the specified element. * * @param obj Element whose presence in this set is to be tested. * @return <tt>true</tt> if this set contains the specified element. */ public boolean contains(final Object obj) { maintain(); return set.contains(WeakObject.create(obj)); }
/** * Removes the given element from this set if it is present. * * @param obj Object to be removed from this set, if present. * @return <tt>true</tt> if the set contained the specified element. */ public boolean remove(final Object obj) { maintain(); return set.remove(WeakObject.create(obj)); }