11_linked_lists_II - CSCI-1200 Data Structures Fall 2010...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CSCI-1200 Data Structures — Fall 2010 Lecture 11 — Linked Lists, Part II Announcements Monday 10/11 is an RPI holiday, no classes. Tuesday 10/12 is a “Monday”, so there will be no Data Structures lecture on Tuesday. Exam 2 will be given on Tuesday 10/19. Review from Lecture 10 Limitations of singly-linked lists Doubly-linked lists: Structure Insert Remove Today’s Lecture Our own version of the STL list<T> class, named dslist Implementing list iterators 11.1 The dslist Class — Overview We will write a templated class called dslist that implements much of the functionality of the std::list<T> container and uses a doubly-linked list as its internal, low-level data structure. Three classes are involved: The node class The iterator class The dslist class itself Below is a basic diagram showing how these three classes are related to each other: Node<float> Node<float> Node<float> dslist<float> list_iterator<float> Node<float>* prev_: float value_: NULL 1.61 Node<float>* prev_: Node<float>* next_: 6.02 float value_: Node<float>* prev_: Node<float>* next_: float value_: 3.14 NULL Node<float>* ptr_: int size_: Node<float>* tail_: Node<float>* head_: 3 Node<float>* next_: For each list object created by a program, we have one instance of the dslist class, and multiple instances of the Node . For each iterator variable (of type dslist<T>::iterator ) that is used in the program, we create an instance of the list_iterator class.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
11.2 The Node Class It is ok to make all members public because individual nodes are never seen outside the list class. Note that the constructors all initialize the pointers to NULL. template <class T> class Node { public: Node( ) : next_(NULL), prev_(NULL) {} T value_; Node<T>* next_; Node<T>* prev_; }; 11.3 The Iterator Class — Desired Functionality Increment and decrement operators (will be operations on pointers).
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/21/2012 for the course CSCI 1200 taught by Professor Cutler during the Fall '08 term at Rensselaer Polytechnic Institute.

Page1 / 4

11_linked_lists_II - CSCI-1200 Data Structures Fall 2010...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online