//modified code from Bailey Java Structures book // C.Pollett 1999 import java.util.*; public class myVector extends Vector { public Iterator elts() { return new myVectorIterator(this); } } class myVectorIterator implements Iterator { myVector theVector; int current; public myVectorIterator(myVector v) // post: constructs an initialized iterator associated with v. { theVector = v; reset(); } public void reset() // post: the iterator is reset to beginning of the traversal { current = 0; } public boolean hasMoreElements() // post: returns true if there is more structure to be traversed. { return current < theVector.size(); } public Object value() // pre: traversal has more elements // post: returns the current value referenced by the iterator { return theVector.elementAt(current); } public Object nextElement() // pre: traversal has more elements // post: increments the iterated traversal { return theVector.elementAt(current++); } }