Source Code Example

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

/** Source code example for "A Practical Introductionto DataStructures and Algori

thm Analysis, 3rd Edition (Java)"by Clifford A. ShafferCopyright 2008-2011 by Cl


ifford A. Shaffer*//** List ADT */public interface List<E> {/** Remove all conte
nts from the list, so it is onceagainempty. Client is responsible for reclaiming
storageused by the list elements. */public void clear();/** Insert an element at
the current location. Theclientmust ensure that the list's capacity is notexcee
ded.@param item The element to be inserted. */public void insert(E item);/** App
end an element at the end of the list. Theclientmust ensure that the list's capa
city is notexceeded.@param item The element to be appended. */public void append
(E item);/** Remove and return the current element.@return The element that was
removed. */public E remove();/** Set the current position to the start of the li
st */public void moveToStart();/** Set the current position to the end of the li
st */public void moveToEnd();/** Move the current position one step left. Nochan
geif already at beginning. */public void prev();/** Move the current position on
e step right. Nochangeif already at end. */public void next();/** @return The nu
mber of elements in the list. */public int length();/** @return The position of
the current element. */public int currPos();/** Set current position.@param pos
The position to make current. */public void moveToPos(int pos);/** @return The c
urrent element. */public E getValue();}

You might also like