### Question:
SparseClusterArray implements Iterable<E> { public Iterator<E> iterator() { return new ElementIterator<E>(); } SparseClusterArray(); protected  SparseClusterArray(SparseClusterArray base); E get(int i); void set(int i, E e); int firstNullIndex(int i, int length); SparseClusterArray<E> deepCopy(Cloner<E> elementCloner); Snapshot<E,T> getSnapshot(Transformer<E,T> transformer); void restore(Snapshot<E,T> snap, Transformer<T,E> transformer); void clear(); void trackChanges(); void stopTrackingChanges(); boolean isTrackingChanges(); Entry<E> getChanges(); void resetChanges(); void revertChanges(Entry<E> changes); String toString(); int numberOfElements(); int numberOfChunks(); IndexIterator getElementIndexIterator(); IndexIterator getElementIndexIterator(int fromIndex); Iterator<E> iterator(); int cardinality(); static final int CHUNK_BITS; static final int CHUNK_SIZE; static final int N_ELEM; static final int SEG_BITS; static final int N_SEG; static final int S1; static final int S2; static final int S3; static final int MAX_CLUSTERS; static final int MAX_CLUSTER_ENTRIES; }### Answer:
@Test public void testIterator() { SparseClusterArray<Integer> arr = new SparseClusterArray<Integer>(); for (int i=0; i<300; i++){ arr.set(i,i); } for (int i=700; i < 1000; i++){ arr.set(i,i); } boolean lastSeen = false; int n = 0; for (Integer i : arr){ if (i == 200){ for (int j = 150; j<750; j++){ arr.set(j, null); } } else if (i == 999){ lastSeen = true; } n++; } assert n == 451 : "wrong number of visited elements: " + n; assert lastSeen : "last element not seen"; }