/** * Specialized Iterator for MyArrayCollection. * * @author R. P. Futrelle * @version 20 June 2003 (started 19 June 2003) */ class MyArrayIterator implements MyIterator { int nextIndexToDo; MyArrayCollection _collection; MyArrayIterator(MyArrayCollection collection) { _collection = collection; nextIndexToDo = 0; } public boolean hasNext() { return nextIndexToDo <= _collection.maxIndexFilled; } // hasNext() public Object next() { // NOT best practice, need exception if (nextIndexToDo > _collection.maxIndexFilled) return null; return _collection.storesIt[nextIndexToDo++]; // increment after use } // next() } // MyArrayIterator