package rebelsky.lists; import java.util.Vector; /** * A vector-based version of simple lists. * * @author CSC152 2005S */ public class VectorBasedSimpleList implements SimpleList { // +--------+-------------------------------------------------- // | Fields | // +--------+ /** * The vector we use to implement the list. */ Vector elements; /** * The size of the list. (Yes, we can use elements.size(), but * I feel safer using our own field.) */ int size; // +--------------+-------------------------------------------- // | Constructors | // +--------------+ /** * Build a new list. */ public VectorBasedSimpleList() { this.elements = new Vector(); this.size = 0; } // VectorBasedSimpleList() // +---------+------------------------------------------------- // | Methods | // +---------+ /** * Add an object somewhere in the list. */ public void add(T addMe) { this.elements.add(addMe); ++this.size; } // add(T) /** * Remove an object from the list. Removes the object * last returned by the iterator. */ public T remove(Cursor position) { // STUB return null; } // remove( /** * Create a new iterator for the list. */ public Cursor newCursor() { return new VectorCursor(this.elements); } // newCursor() /** * Convert to a string for printing. */ public String toString() { return this.elements.toString(); } // toString() } // class VectorBasedSimpleList