Lists Lecture 16 Fri, Mar 3, 2006. Topics Lists List ADT Attributes Constructors Destructor...
-
Upload
vanessa-page -
Category
Documents
-
view
212 -
download
0
Transcript of Lists Lecture 16 Fri, Mar 3, 2006. Topics Lists List ADT Attributes Constructors Destructor...
![Page 1: Lists Lecture 16 Fri, Mar 3, 2006. Topics Lists List ADT Attributes Constructors Destructor Inspectors Mutators Facilitators Operators Other List Functions.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e695503460f94b66155/html5/thumbnails/1.jpg)
Lists
Lecture 16
Fri, Mar 3, 2006
![Page 2: Lists Lecture 16 Fri, Mar 3, 2006. Topics Lists List ADT Attributes Constructors Destructor Inspectors Mutators Facilitators Operators Other List Functions.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e695503460f94b66155/html5/thumbnails/2.jpg)
Topics
Lists List ADT
Attributes Constructors Destructor Inspectors Mutators Facilitators Operators Other List Functions
![Page 3: Lists Lecture 16 Fri, Mar 3, 2006. Topics Lists List ADT Attributes Constructors Destructor Inspectors Mutators Facilitators Operators Other List Functions.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e695503460f94b66155/html5/thumbnails/3.jpg)
Lists
A list is an ordered set of elements
{a1, …, an}
The indexing begins at 1, not 0. The elements ai may be of any type.
But they must all be of the same type. The structure is homogeneous.
A list is a generalization of an array.
![Page 4: Lists Lecture 16 Fri, Mar 3, 2006. Topics Lists List ADT Attributes Constructors Destructor Inspectors Mutators Facilitators Operators Other List Functions.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e695503460f94b66155/html5/thumbnails/4.jpg)
List ADT: List Attributes
A list has a size elements a1 through asize.
![Page 5: Lists Lecture 16 Fri, Mar 3, 2006. Topics Lists List ADT Attributes Constructors Destructor Inspectors Mutators Facilitators Operators Other List Functions.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e695503460f94b66155/html5/thumbnails/5.jpg)
List ADT: Constructors
Constructors
List();List(int sz);List(int sz, const T& value);List(const List& lst);
![Page 6: Lists Lecture 16 Fri, Mar 3, 2006. Topics Lists List ADT Attributes Constructors Destructor Inspectors Mutators Facilitators Operators Other List Functions.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e695503460f94b66155/html5/thumbnails/6.jpg)
List ADT: Destructor
Destructor
~List();
![Page 7: Lists Lecture 16 Fri, Mar 3, 2006. Topics Lists List ADT Attributes Constructors Destructor Inspectors Mutators Facilitators Operators Other List Functions.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e695503460f94b66155/html5/thumbnails/7.jpg)
List ADT: Inspectors
Inspectors
T& getElement(int pos) const;int size() const;bool isEmpty() const;
![Page 8: Lists Lecture 16 Fri, Mar 3, 2006. Topics Lists List ADT Attributes Constructors Destructor Inspectors Mutators Facilitators Operators Other List Functions.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e695503460f94b66155/html5/thumbnails/8.jpg)
List ADT: Mutators
Mutators
void setElement(int pos, const T& value);void insert(int pos, const T& value);void remove(int pos);void makeEmpty();
![Page 9: Lists Lecture 16 Fri, Mar 3, 2006. Topics Lists List ADT Attributes Constructors Destructor Inspectors Mutators Facilitators Operators Other List Functions.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e695503460f94b66155/html5/thumbnails/9.jpg)
List ADT: Mutators
Additional Mutators
void pushFront(const T& value);void pushBack(const T& value);T popFront();T popBack();
![Page 10: Lists Lecture 16 Fri, Mar 3, 2006. Topics Lists List ADT Attributes Constructors Destructor Inspectors Mutators Facilitators Operators Other List Functions.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e695503460f94b66155/html5/thumbnails/10.jpg)
List ADT: Facilitators
Facilitators
void input(istream& in);void output(ostream& out) const;
![Page 11: Lists Lecture 16 Fri, Mar 3, 2006. Topics Lists List ADT Attributes Constructors Destructor Inspectors Mutators Facilitators Operators Other List Functions.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e695503460f94b66155/html5/thumbnails/11.jpg)
List ADT: Operators
Operators
List& operator=(const List& lst);T& operator[](int pos);
![Page 12: Lists Lecture 16 Fri, Mar 3, 2006. Topics Lists List ADT Attributes Constructors Destructor Inspectors Mutators Facilitators Operators Other List Functions.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e695503460f94b66155/html5/thumbnails/12.jpg)
List ADT: Other Member Functions
Other Member Functions
void swap(List& lst);int search(const T& value) const;void sort();bool isValid() const;