1 19 package gnu.trove; 20 21 import java.util.ConcurrentModificationException ; 22 import java.util.Iterator ; 23 import java.util.NoSuchElementException ; 24 25 46 abstract class THashIterator<V> extends TIterator implements Iterator <V> { 47 protected final TObjectHash _hash; 48 49 52 public THashIterator(TObjectHash hash) { 53 super(hash); 54 _hash = hash; 55 } 56 57 66 public V next() { 67 moveToNextIndex(); 68 return objectAtIndex(_index); 69 } 70 71 80 protected final int nextIndex() { 81 if (_expectedSize != _hash.size()) { 82 throw new ConcurrentModificationException (); 83 } 84 85 Object [] set = _hash._set; 86 int i = _index; 87 while (i-- > 0 && (set[i] == TObjectHash.FREE || set[i] == TObjectHash.REMOVED)) ; 88 return i; 89 } 90 91 99 abstract protected V objectAtIndex(int index); 100 } | Popular Tags |