public Iterator iterator ( ) { // remove garbage collected elements processQueue ( ) ; // get an iterator of the superclass WeakHashSet final Iterator i = super . iterator ( ) ; return new Iterator ( ) { public boolean hasNext ( ) { return i . hasNext ( ) ; } public Object next ( ) { // unwrap the element return getReferenceObject ( ( WeakReference ) i . next ( ) ) ; } public void remove ( ) { // remove the element from the HashSet i . remove ( ) ; } } ; }
Returns an iterator over the elements in this set . The elements are returned in no particular order .