Yurttas/PL/OOL/Cplusplus/F/05/04/03/01/sort.cpp
Jump to navigation
Jump to search
1/*
2 Copyright(C) 2002
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 date : January 1, 2002.
11 author : Salih Yurttas.
12
13 sort.cpp
14*/
15
16
17#include "sort.h"
18
19using namespace std;
20
21template <class T, class C>
22void sort(vector<T>& list,
23 const C& compare) {
24 get_vector_item(list);
25
26 char sort_decision = get_char("B|I|Q|S");
27
28 switch((BIQS)(toupper(sort_decision))) {
29 case BubbleSort : bubblesort(list,
30 compare);
31 break;
32 case InsertionSort : insertionsort(list,
33 compare);
34 break;
35 case QuickSort : quicksort(list,
36 compare);
37 break;
38 case SelectionSort : selectionsort(list,
39 compare);
40 break;
41 default : cerr << "Error: sort_decision should be B|I|Q|S" << endl;
42 exit(1);
43 }
44
45 put_vector_item(list);
46}