- 98 Views
- Uploaded on
- Presentation posted in: General

CS 302 Data Structures

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

CS 302 Data Structures

Linked Lists

- A Node:
- Several nodes linked together

- A head pointer to the first node

// Programming exercise 2

void moveToBeginning ()

throw (logic_error);

// Programming exercise 3

void insertBefore(constDataType& newDataItem)

throw (logic_error);

void showStructure() const;

private:

class ListNode {

public:

ListNode(const DataType& nodeData,

ListNode* nextPtr);

DataTypedataItem;

ListNode* next;

};

ListNode* head;

ListNode* cursor;

};

template <typenameDataType>

class List {

public:

List(int ignored = 0);

List(const List& other);

List& operator=(const List& other);

~List();

void insert(constDataType& newDataItem)

throw (logic_error);

void remove() throw (logic_error);

void replace(constDataType& newDataItem)

throw (logic_error);

void clear();

boolisEmpty() const;

boolisFull() const;

void gotoBeginning() throw (logic_error);

void gotoEnd() throw (logic_error);

boolgotoNext() throw (logic_error);

boolgotoPrior() throw (logic_error);

DataTypegetCursor() const throw (logic_error);

- Constructor
- Destructor
- operator=
- Shallow Copy vs Deep Copy

- …