ssing keys/values through an iterator: for (TIntObjectIterator it = map.iterator(); it.hasNext();) { it.advance(); if (satisfiesCondition(it.key()) { doSomethingWithValue(it.value()); } }
// modifying values in-place through iteration: for (TIntObjectIterator it = map.iterator(); it.hasNext();) { it.advance(); if (satisfiesCondition(it.key()) { it.setValue(newValueForKey(it.key())); } }
// deleting entries during iteration: for (TIntObjectIterator it = map.iterator(); it.hasNext();) { it.advance(); if (satisfiesCondition(it.key()) { it.remove(); } }
// faster iteration by avoiding hasNext(): TIntObjectIterator iterator = map.iterator(); for (int i = map.size(); i-- > 0;) { iterator.advance(); doSomethingWithKeyAndValue(iterator.key(), iterator.value()); }
@author Eric D. Friedman
@version $Id: P2OIterator.template,v 1.1 2006/11/10 23:28:00 robeden Exp $