-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsort.h
50 lines (41 loc) · 1.46 KB
/
sort.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//============================================================================
// Name : sort.h
// Author :
// Date :
// Copyright :
// Description : Sort interface and various sorting algorithms in C++
//============================================================================
#ifndef SORT_H_
#define SORT_H_
class Sort {
protected:
unsigned long long num_cmps; // number of comparisons performed in sort function
public:
virtual void sort(int A[], int size) = 0; // main entry point
bool testIfSorted(int A[], int size); // returns false if not sorted
// true otherwise
unsigned long long getNumCmps() { return num_cmps; } // returns # of comparisons
void resetNumCmps() { num_cmps = 0; }
};
class SelectionSort:public Sort { // SelectionSort class
public:
void sort(int A[], int size); // main entry point
};
class InsertionSort:public Sort { // InsertionSort class
public:
void sort(int A[], int size); // main entry point
};
class BubbleSort:public Sort { // BubbleSort class
public:
void sort(int A[], int size); // main entry point
};
class ShellSort:public Sort { // ShellSort class
public:
void sort(int A[], int size); // main entry point
inline int next_space(int space);
};
class RadixSort:public Sort { // RadixSort class
public:
void sort(int A[], int size); // main entry point
};
#endif //SORT_H_