Rice University - Comp 212 - Intermediate Programming
Fall 2002
Lecture #4 - Immutable Recursive List Structure (still under
construction...)
Today's menu:
- Review the OO Pizza model and code and discuss some more syntax.
- OO formulation of list structure.
1. Another look at the Pizza model
What's good about it?
What's bad about it?
What about comparing deals for more than two pizzas? We need a list of
pizzas!
2. The List Structure
The list structure is one of the most fundamental data structures in programming.
The following is a common definition of a list.
- A list is either empty or non-empty. If it is empty it contains no elements.
If is not empty, it contains an element called first and an element called rest,
which is itself a list.
We rephrase the above as follows.
- There is an abstract notion of a list. A list knows how to call an
algorithm to operate on itself with a given input and produce an output.
An empty list is a list. It has no first and no rest element.
A non-empty list is a list. It has an element called first and an element called
rest, which is itself another list.
Click here to see the UML for the list structure.
Click here to see the code for the list structure.
Click here to see the code for algorithms on the list
structure.
Click here to see the code for a concrete list factory.
Click here to download the binary file for the list framework
and the concrete list factory.
dxnguyen@cs.rice.edu, last revised
09/04/02