1--
2-- Copyright (C) 1998
3-- All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4--
5-- Permission to use, copy, modify, and distribute this
6-- software and its documentation for EDUCATIONAL purposes
7-- and without fee is hereby granted provided that this
8-- copyright notice appears in all copies.
9--
10--
11
12-- date : January 1, 1998.
13-- author : Salih Yurttas.
14
15-- purpose : sorting varying length strings using access type
16-- by choice of bubble or quick sort algorithm.
17
18-- sorti_a_00.adb
19
20
21with Text_IO; use Text_IO;
22
23with ListIF_P; use ListIF_P;
24with IO_ListI_P; use IO_ListI_P;
25
26with SortEL_AD_00_P;
27
28procedure SortI_A_00 is
29
30 Max_Size : constant Integer := 16;
31
32 Sort_Decision : Character;
33
34 Data_List_Count : Integer;
35
36 Data_ListI : ListI(1..Max_Size);
37
38 PageHeader : constant String :=
39 "The sorted list of integers in ascending order are :";
40
41 package SortIA is new SortEL_AD_00_P(Element => Integer,
42 ListE => ListI,
43 Compare => "<"); use SortIA;
44begin
45
46 -- get the type of the sort algorithm choice.
47
48 Put("--> B_S_I_Q : B for Bublesort,"); New_Line;
49 Put(" S for Selection, "); New_Line;
50 Put(" I for Insertion, "); New_Line;
51 Put(" Q for Quicksort : ");
52
53 Get(Sort_Decision); Skip_Line;
54 New_Line;
55
56 case Sort_Decision is
57 when 'B' | 'b' => GetIL(Data_List_Count, Data_ListI);
58 Bubble_SortE(Data_List_Count, Data_ListI);
59 PutIL(Data_List_Count, Data_ListI, PageHeader);
60
61 when 'S' | 's' => GetIL(Data_List_Count, Data_ListI);
62 Select_SortE(Data_List_Count, Data_ListI);
63 PutIL(Data_List_Count, Data_ListI, PageHeader);
64
65 when 'I' | 'i' => GetIL(Data_List_Count, Data_ListI);
66 Insert_SortE(Data_List_Count, Data_ListI);
67 PutIL(Data_List_Count, Data_ListI, PageHeader);
68
69 when 'Q' | 'q' => GetIL(Data_List_Count, Data_ListI);
70 Quick_SortE(1, Data_List_Count, Data_ListI);
71 PutIL(Data_List_Count, Data_ListI, PageHeader);
72
73 when others => null;
74 end case;
75
76end SortI_A_00;