I have finished writing my Dynamic, Linked-List implementation of the ADT List, but I can't figure out what the book includes the "void retrieve" function for. Insertion, deletion, the constructors, deconstructors, etc. all have clear purposes, but what is the purpose of the retrieval operation? The header file (class declaration) looks like this:
typedef int ListItemType;
class List
{
public:
List(); //constructor
List(const List& aList); // copy constructor
~List(); //destructor
void display(); //output
bool isEmpty() const; //checks for empty
int getLength() const;
void insert_node(int index, const ListItemType& newItem) //inserts node
throw (ListIndexOutOfRangeException, ListException);
void delete_node(int index) //deletes node
throw (ListIndexOutOfRangeException);
void retrieve (int index, ListItemType& dataItem) const
throw (ListIndexOutOfRangeException);
private:
struct ListNode //A node on the list
{
ListItemType item;
ListNode *next;
}; //end ListNode
int size;
ListNode *head;
ListNode *find(int index) const;
}; //end List