1
7/18/2019 Source Code Example http://slidepdf.com/reader/full/source-code-example 1/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();}

Source Code Example

Embed Size (px)

DESCRIPTION

Practical example

Citation preview

Page 1: Source Code Example

7/18/2019 Source Code Example

http://slidepdf.com/reader/full/source-code-example 1/1

/** Source code example for "A Practical Introductionto DataStructures and Algorithm Analysis, 3rd Edition (Java)"by Clifford A. ShafferCopyright 2008-2011 by Clifford A. Shaffer*//** List ADT */public interface List<E> {/** Remove all contents from the list, so it is onceagainempty. Client is responsible for reclaimingstorageused by the list elements. */public void clear();/** Insert an element at the current location. Theclientmust ensure that the list's capacity is notexceeded.@param item The element to be inserted. */public void insert(E item);/** Append an element at the end of the list. Theclientmust ensure that the list's capacity is notexceeded.@param item The element to be appended. */public void append(E item);/** Remove and return the current element.@return The element that wasremoved. */public E remove();/** Set the current position to the start of the list */public void moveToStart();/** Set the current position to the end of the list */public void moveToEnd();/** Move the current position one step left. Nochangeif already at beginning. */public void prev();/** Move the current position one step right. Nochangeif already at end. */public void next();/** @return The number of elements in the list. */public int length();/** @return The position ofthe current element. */public int currPos();/** Set current position.@param posThe position to make current. */public void moveToPos(int pos);/** @return The current element. */public E getValue();}