-- Item : Generic Contingous Keyed List Test Procedure -- Reference : Data Structures and Program Design, Pascal, p 198 -- Author : Paul Stachour, stachour@winternet.com -- Version : 1.0, 1999/Jan/28 -- For : ICS340, Winter 199, Metro State, Minnesota -- Style : Ada95, in a pascalish style, to match the textbook. -- Style : Ada95, in an ada style, to show type paramaterization -- Protection: Written 1999,This code is available to the public with adg_cl; with text_io; use text_io; procedure adg_tp is -- This file tests some aspects of a contiguous list package with the -- part common to all types of list entries. package Int_IO is new text_io.integer_io( Integer ); type Int_Data is new Integer; Int_Item: Int_Data; package Int_Data_IO is new text_io.integer_io( Int_Data ); package Int_Cl is new adg_cl(10, Int_Data); use Int_Cl; Int_List: Int_Cl.List; procedure Print_LE(LE: in out Int_Data) is begin Int_Data_IO.Put( LE ); Text_IO.New_Line; end; type Char_Data is new character; package Char_Data_IO is new text_io.enumeration_io( Char_Data ); package Char_Cl is new adg_cl(20, Char_Data); use Char_Cl; Char_List: Char_Cl.List; procedure Print_LE(LE: in out Char_Data) is begin Char_Data_IO.Put( LE ); Text_IO.New_Line; end; begin -- main procedure CreateList( Int_List ); InsertList( LE => 1, P => 1, L => Int_List ); InsertList( LE => 2, P => 1, L => Int_List ); Text_IO.Put("List should have " & Integer'Image(ListSize(L=>Int_List)) & " Entries in the list." ); Text_IO.New_Line; TraverseList( L=> Int_List, Visit => Print_LE'access ); text_IO.New_line(2); InsertList( LE => 3, P => 1, L => Int_List ); InsertList( LE => 4, P => 1, L => Int_List ); Text_IO.Put("List should have 4 Entries in the list." ); Text_IO.New_Line; TraverseList( L=> Int_List, Visit => Print_LE'access ); text_IO.New_line(2); ClearList( L => Int_List ); Text_IO.Put("List should have 0 Entries in the list." ); Text_IO.New_Line; TraverseList( L=> Int_List, Visit => Print_LE'access ); text_IO.New_line(2); InsertList( LE => 1, P => 1, L => Int_List ); InsertList( LE => 3, P => 2, L => Int_List ); InsertList( LE => 2, P => 2, L => Int_List ); InsertList( LE => 4, P => 4, L => Int_List ); Text_IO.Put("List should have 4 Entries in the list." ); Text_IO.New_Line; TraverseList( L=> Int_List, Visit => Print_LE'access ); text_IO.New_line(2); InsertList( LE => 2, P => 2, L => Int_List ); InsertList( LE => 2, P => 2, L => Int_List ); Text_IO.Put("List should have 6 Entries in the list." ); Text_IO.New_Line; TraverseList( L=> Int_List, Visit => Print_LE'access ); text_IO.New_line(2); InsertList( LE => -1, P => 5, L => Int_List ); InsertList( LE => -2, P => 5, L => Int_List ); InsertList( LE => -3, P => 5, L => Int_List ); InsertList( LE => -4, P => 5, L => Int_List ); Text_IO.Put("List should have 10 Entries in the list." ); Text_IO.New_Line; TraverseList( L=> Int_List, Visit => Print_LE'access ); text_IO.New_line(2); Text_IO.Put("Next insert should fail - List is full." ); Text_IO.New_Line; InsertList( LE => 11, P => 5, L => Int_List ); DeleteList( LE => Int_Item, P => 5, L => Int_List ); Text_IO.Put("Deleted item with value of "); Int_data_IO.Put( Int_Item); Text_IO.Put( " from the list. We now have " & Integer'Image(ListSize(L=>Int_List)) & " Items in the list." ); Text_IO.New_Line; CreateList( Char_List ); end adg_tp;