package rebelsky.lists; import java.util.Vector; /** * Iterators that step over the values in a vector. * * @author CSC152 2005S */ public class VectorCursor implements Cursor { // +--------+-------------------------------------------------- // | Fields | // +--------+ /** * The current position in the vector. */ int pos; /** * The vector we're iterating. */ Vector vec; // +--------------+-------------------------------------------- // | Constructors | // +--------------+ /** * Create a new cursor for a particular vector. */ public VectorCursor(Vector _vec) { this.vec = _vec; } // VectorCursor() // +---------+------------------------------------------------- // | Methods | // +---------+ public T next() { T tmp = vec.get(this.pos); // Error checking handled by vec this.pos++; return tmp; } // next() public boolean hasNext() { return this.pos < this.vec.size(); } // hasNext() } // class VectorCursor