IdentityHashSet extends AbstractSet<E> { @Override public Iterator<E> iterator() { return map.keySet().iterator(); } IdentityHashSet(); @Override boolean add(E e); @Override void clear(); @Override boolean contains(Object o); @Override boolean isEmpty(); @Override Iterator<E> iterator(); @Override boolean remove(Object o); @Override int size();  }
@Test public final void testIterator() { Iterator<Object> i = s.iterator(); assertTrue(i != null && !i.hasNext()); for (int j = 0; j < o.length; j++) s.add(o[j]); i = s.iterator(); assertTrue(i != null); for (int j = 0; j < o.length; j++) { assertTrue(i != null && i.hasNext() && i.next() != null); } }