1 / 6

CS 302 Data Structures

CS 302 Data Structures. Linked Lists. Preliminaries. A Node: Several nodes linked together. Preliminaries. A head pointer to the first node. Time for some code:. // Programming exercise 2 void moveToBeginning () throw ( logic_error ); // Programming exercise 3

gypsy
Download Presentation

CS 302 Data Structures

An Image/Link below is provided (as is) to download presentation 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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 302 Data Structures Linked Lists

  2. Preliminaries • A Node: • Several nodes linked together

  3. Preliminaries • A head pointer to the first node

  4. Time for some code: // 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);

  5. Now to write some …. • Constructor • Destructor • operator= • Shallow Copy vs Deep Copy • …

  6. End of Chapter 4

More Related