Now that we have discussed a large amount of the preliminary material related to the C+ + language, we want to begin our discussion of Abstract Data Structures (ADT's) with the list ADT. The list ADT consists of a finite collection of data of type TYPE together with information about the location of the other elements in the list. A double linked list or DLLIST then contains the finite collection of elements
arranged in a chain
Since each element ai has a corresponding compiler generated
address pi, we will use the convention that
the two sided arrows
indicate that
we store the address of each element ai's predecessor ai - 1
successor ai + 1 in some fashion. Some method of storing this
triple of information is then required. In general, we then
need a block of storage of the form
[TYPE a] [TYPE *p] [TYPE *s] where p and s
denote the predecessor and successor address, respectively.
Storing both predecessor and successor address information requires, of course, a bit more storage, so another way of organizing the list is to only store the successor information. This generates the chain
which only requires us to store the addresses of successors.
Note that we use a one sided arrow
to denote this
choice. We require less storage in this case, using blocks of the
form [TYPE a] [TYPE *s]. This is the singly linked list or
SLLIST.
A third common type of linked list is the circular chain, in which the successor of the last element in the list is considered to be the first element.
In this chapter, we will implement these sorts of lists using a core class LIST_CORE with various derived children. In general, the list ADT requires several important methods or agents in order to do useful work with the list ADT. These agents will
We will design our core class LIST_CORE with the agents above declared pure virtual and then proceed to derive children for the various list possibilities.