|
|
|
|
|
|
|
// Remainder of list2 (except the sentinel) is
// appended to mergedList@entry
// ELSE
// Remainder of list1 (except the sentinel) is
// appended to mergedList@entry
// & The last element of mergedList is the (only) sentinel record
{
// Append rest of list1, if more exists
while (strcmp(list1[index1].lastName, SENTINEL) != 0)
{
// Invariant (prior to test):
// mergedList[[email protected]] contain
// the elements of list1[[email protected]]
// & The sentinel is not in list1[0..index1-1]
mergedList[index3] = list 1[index1];
index1++;
index3++;
}
// Append rest of list2, if more exists
while (strcmp(list2[index2].lastName, SENTINEL) != 0)
{
// Invariant (prior to test):
// mergedList[[email protected]] contain
// the elements of list2[[email protected]]
// && The sentinel is not in list2[0..index2-1]
mergedList[index3] = list2[index2];
index2++;
index3++;
}
// Store sentinel record
mergedList[index3] = list2[index2];
}
//******************************************************************
void Write( /* in */ const PersonRec masterList[], // Merged list
/* inout */ ofstream& masterFile ) // Output file
// Writes the contents of masterList to masterFile
|
|
|
|
|
|