next up previous contents
Next: Testing MergeSort: Up: Using Various SLLIST Objects: Previous: Testing the Overloaded Equal:

Testing the Insertion Agents:

  cout << "Instantiating List Qaitlin" << endl;
  INT_SLLIST Qaitlin("intQa1");

  cout << endl << "Building Qaitlin List" << endl;
  Qaitlin.build_list(input,3);
  cout << "Qaitlin has " << Qaitlin.get_number_elements() << " elements";
  cout << endl;
  cout << endl << "Qaitlin = " << endl << Qaitlin << endl;

  cout << endl << "Insert element 10 after 3" << endl;
  Qaitlin.insert_after(3,10);
  cout << endl << "Qaitlin = " << Qaitlin;

  cout << endl << "Insert element 20 after 2" << endl;
  Qaitlin.insert_after(2,20);
  cout << endl << "Qaitlin = " << Qaitlin;

  cout << "Qaitlin has " << Qaitlin.get_number_elements() << " elements";
  }

The corresponding output is:

Instantiating List Qaitlin
In default SLLIST<intQa1> constructor.
Exit default SLLIST<intQa1> constructor.

Building Qaitlin List
In SLLIST<intQa1> build_list.
Exit SLLIST<intQa1> build_list.
Qaitlin has 3 elements

Qaitlin = 
2-->2-->3.

Insert element 10 after 3
Entering the SLLIST insert_after.
In SLLIST get_after_element_address.
In SLLIST get_element_adress.
Leaving the SLLIST insert_after.

Qaitlin = 2-->2-->3-->10.


Insert element 20 after 2
Entering the SLLIST insert_after.
In SLLIST get_after_element_address.
search_key is at head of list, so after address is head->next.
In SLLIST get_element_adress.
Leaving the SLLIST insert_after.

Qaitlin = 2-->20-->2-->3-->10.

Qaitlin has 5 elements
Entering SLLIST<intQa1> destructor.
     Removing SL_CELL -1
         Removing SL_CELL 0
             Removing SL_CELL 1
                 Removing SL_CELL 2
                     Removing SL_CELL 3
Leaving SLLIST destructor.



Jim Peterson
1999-04-22