Download presentation
Presentation is loading. Please wait.
1
Lecture 15 Section 6.1 Mon, Feb 26, 2007
Lists Lecture 15 Section 6.1 Mon, Feb 26, 2007
2
Lists A list is an ordered set of elements {a1, …, an}
The indexing begins at 1, not 0. a1 is at the head of the list. an is at the tail of the list. 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.
3
List ADT: List Attributes
A list has a size elements a1 through asize.
4
List ADT: Constructors
List(int sz); List(int sz, const T& value); List(const List& lst);
5
List ADT: Destructor Destructor ~List();
6
List ADT: Inspectors Inspectors T getElement(int pos) const;
int size() const; bool isEmpty() const;
7
List ADT: Mutators Mutators void setElement(int pos, const T& value);
void insert(int pos, const T& value); void remove(int pos); void makeEmpty();
8
List ADT: Mutators Additional Mutators void pushFront(const T& value);
void pushBack(const T& value); T popFront(); T popBack();
9
List ADT: Facilitators
void input(istream& in); void output(ostream& out) const;
10
List ADT: Operators Operators List& operator=(const List& lst);
T& operator[](int pos);
11
List ADT: 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.