Get Info Demo Program
version 5.0

In version 4 we implemented two indecies for names: an index based on last name,
and one based on the first letter of the last name.  In this version we will
implement searching routines that take advantage of these indecies.

The first thing we will do, however, is merely housecleaning.  The list of prototypes
for local routines is getting pretty long, so we will move it to the header routine.
Since we split off the ADT part of the header file into stuff.h, there really hasn't
been much there except for the defines.

Now that we are ready to start implementing the search routines, we find that the
original routine, find_names, isn't what we really want.  Since we have implemented
two different indexing methods, we will demonstrate three kinds of searches: a
sequential search, a search using a full index, and a search using the partial index.

The sequential search is very easy, but slow.  We simply loop through the list
looking for a match.  As soon as we detect that we have gone past what we are looking
for, we can quit.  This is because the list is in alphabetical order.  We could also
search through the original ProdPtrList, but we would have to examine the entire list,
since the entries are not in any order.

The general algorithm for searching is to loop and compare last names.  If the desired
name is less than the current last name, then we still have further to search.  If
the desired name is less than the desired entry, then we have passed any matches.
If the last names match, then a test is made to see if the first name was specified.
If the user has specified a first name, then we use the same algorithm to find a match.
Any entries that match the desired name will be displayed.  If an index is available,
then we can use the index to start close to the desired entries.

The full index is implemented using a ProdAPtrList which has a key and a data pointer.
The key being used is the last name.  This only affects the full index, since the
sequential search doesn't use any index, and the partial index is based only on the
first character of the name.  For a full index search, we look for the last name in
the index.  If no entry is found, then there are no entries with that last name.  If
there are any entries, the index entry points to the first link containing that name.
The routine then loops through the list until we have gone past any matches.

The partial index is basedon the first letter of the last name.  If the corresponding
index entry is NULL, then clearly there are no matches.  Otherwise, we start at the
first entry starting with the same first letter, and continue until we pass where
any matches would be.

Notice that both the full and partial indecies consist of pointers to links within
the alphabetical list.  The index tells us where to start looking in the list.  The
full index will get us closer to any matches, while the partial index will only get
us to the start of the letter.

When we tried testing the partial index using the test file we created with genstuff,
we find that all the entries start with the same letter.  So we modified the program
to insert a random character as the first letter of the last name.  We also reduced
the random number is the last name from two to one digits.  This makes it easier to
find duplicate entries for testing.  We also reduced the first name random number
from two to one digits.
