Lists Lecture 16 Fri, Mar 3, 2006
Topics Lists List ADT Attributes Constructors Destructor Inspectors Mutators Facilitators Operators Other List Functions
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.
List ADT: List Attributes A list has a size elements a 1 through a size.
List ADT: Constructors Constructors List(); List(int sz); List(int sz, const T& value); List(const List& lst);
List ADT: Destructor Destructor ~List();
List ADT: Inspectors Inspectors T& getElement(int pos) const; int size() const; bool isEmpty() const;
List ADT: Mutators Mutators void setElement(int pos, const T& value); void insert(int pos, const T& value); void remove(int pos); void makeEmpty();
List ADT: Mutators Additional Mutators void pushFront(const T& value); void pushBack(const T& value); T popFront(); T popBack();
List ADT: Facilitators Facilitators void input(istream& in); void output(ostream& out) const;
List ADT: Operators Operators List& operator=(const List& lst); T& operator[](int pos);
List ADT: Other Member Functions Other Member Functions void swap(List& lst); int search(const T& value) const; void sort(); bool isValid() const;