Download presentation
Presentation is loading. Please wait.
Published byVanessa Page Modified over 9 years ago
1
Lists Lecture 16 Fri, Mar 3, 2006
2
Topics Lists List ADT Attributes Constructors Destructor Inspectors Mutators Facilitators Operators Other List Functions
3
Lists A list is an ordered set of elements {a 1, …, a n } The indexing begins at 1, not 0. The elements a i 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.
4
List ADT: List Attributes A list has a size elements a 1 through a size.
5
List ADT: Constructors Constructors List(); List(int sz); List(int sz, const T& value); List(const List& lst);
6
List ADT: Destructor Destructor ~List();
7
List ADT: Inspectors Inspectors T& getElement(int pos) const; int size() const; bool isEmpty() const;
8
List ADT: Mutators Mutators void setElement(int pos, const T& value); void insert(int pos, const T& value); void remove(int pos); void makeEmpty();
9
List ADT: Mutators Additional Mutators void pushFront(const T& value); void pushBack(const T& value); T popFront(); T popBack();
10
List ADT: Facilitators Facilitators void input(istream& in); void output(ostream& out) const;
11
List ADT: Operators Operators List& operator=(const List& lst); T& operator[](int pos);
12
List ADT: Other Member Functions Other Member Functions void swap(List& lst); int search(const T& value) const; void sort(); bool isValid() const;
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.