```lists101
Ch9.1-9.3	Using Lists
Objectives:
To be able to recall the names of list operations and algorithms.
To be able to recall the prototypes/headers for list operations and
algorithms.
Given the name or symbol of  a list operation describe its purpose.
To be able solve problems and code functions by using the C++ list
and algorithm library -- when such code is simple (less than about 10
lines).
To be able to predict the O() performance of standard list
operations/algorithms.

From the Book
http://ftp.csci.csusb.edu/dick/cs330/Slides/ch09slide.pdf

Vectors are not lists!
http://ftp.csci.csusb.edu/dick/cs330/Slides/ch09lists.gif

Linked two way lists

p188: list of list  operations and list::iterator operations.
postit notes!
MUST use iterators instead of indices!
Many iterators moving in parallel or at different speeds.
The moving finger writes and moves on....
INSERTING in the middle.

DANGER: after erase(p);
p is invalid, do not use p.
reset it:  p=...;
Tend to copy an iterator and move it to safety.

Also lists have <algorithm> operations from p174!

p191: extra error with new standard count
num = count(....)

pp191-193.  Iterators vs inserters
When using any standard algorithms in <algorithm> -- for example 'copy'.
To overwrite existing items use an iterator to mark the target.
To add new items use an inserter.
back_inserter(container) -- ok for vectors, deques, lists
front_inserter(container) -- ok for deques and lists
inserter(container, iterator) -- ok for lists and sets.

Vectors are not lists or are they?
Exercise: compare page 188 with page 170

Exercise:  redo ex2 from ch08 using a list of strings
instead of a vector of strings:
Last class we did:
string join(vector<string>& values, string & separator);
http://ftp.csci.csusb.edu/dick/cs330/SourceCode/join.cpp
Now do:
string join(list<string>& values, string & separator);

insert iterators:  magic.

9.3.1: widgets ... slide
http://ftp.csci.csusb.edu/dick/cs330/Slides/ch09widgets.gif
9.3.2 registration... slide
http://ftp.csci.csusb.edu/dick/cs330/Slides/ch09registration.gif

AGAIN: when you erase don't touch it.

Questions?

Vectors are not lists -- again!
http://ftp.csci.csusb.edu/dick/cs330/Slides/ch09splicinglists.txt

Exercises:
Ex 8 on page 215.
template <class T> list<T> append( list<T>, list<T> );

Study Questions 1..9 from p215.

next implementing lists - ch9.4...
Prepare
review pointers.
Look in cs330/links.html for pointer pointers.
Study book 9.4 to end of chapter 9.
Study Qns 11..18 page 215.
Do Qn 10 by Drawing an UML diagram of the classes, pointers, and components
on pages 203..207 (no operators or attributes).

```