1 19 package gnu.trove; 20 21 import java.util.ConcurrentModificationException ; 22 import java.util.NoSuchElementException ; 23 24 32 abstract class TIterator { 33 34 protected final THash _hash; 35 37 protected int _expectedSize; 38 39 protected int _index; 40 41 44 public TIterator(THash hash) { 45 _hash = hash; 46 _expectedSize = _hash.size(); 47 _index = _hash.capacity(); 48 } 49 50 56 public boolean hasNext() { 57 return nextIndex() >= 0; 58 } 59 60 66 public void remove() { 67 if (_expectedSize != _hash.size()) { 68 throw new ConcurrentModificationException (); 69 } 70 _hash.removeAt(_index); 71 _expectedSize--; 72 } 73 74 78 protected final void moveToNextIndex() { 79 if ((_index = nextIndex()) < 0) { 82 throw new NoSuchElementException (); 83 } 84 } 85 86 92 abstract protected int nextIndex(); 93 } | Popular Tags |