-
Notifications
You must be signed in to change notification settings - Fork 0
/
Arraylist.h
73 lines (68 loc) · 2.1 KB
/
Arraylist.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#pragma once
#include "List.h"
class ArrayList :
public List
{
public:
//创建类函数
int CreateFromString(char *list);
int CreateInOrder(int list_length);
int CreateRandom(int list_length, int low,int high);
void Shuffle();
//线性表基本操作
const static int MAXSIZE = 9999;
const static int ERROR = 0x7FFFFFFF;
int LocateElement(int element);
int GetElement(int location);
int Insert(int location,int element);
int Delete(int location);
void Initialize();
int ShowAll();
int IsEmpty();
int IsFull();
//排序相关函数
static int Smaller(int a, int b);
static int Greater(int a, int b);
int IsSorted(int(*compare)(int, int));
int IsSorted();
static const int SORT_MONKEY = 0;
static const int SORT_COUNT=1;
static const int SORT_INSERT= 2;
static const int SORT_BINARY_INSERT = 3;
static const int SORT_SHELL = 4;
static const int SORT_BUBBLE = 5;
static const int SORT_QUICK = 6;
static const int SORT_SELECT = 7;
static const int SORT_DOUBLE_BUBBLE =8;
static const int SORT_HEAP = 9;
static const int SORT_MERGE = 10;
static const int SORT_RADIX = 11;
static const int SORT_GOBLIN = 12;
int Sort(int sort_method, int(*compare)(int, int));
int Sort(int sort_method);
//构造与析构
ArrayList();
ArrayList(char *list);
~ArrayList();
protected:
int data[MAXSIZE];
void MonkeySort(int(*compare)(int, int));
void InsertSort(int(*compare)(int, int));
void BinaryInsertSort(int(*compare)(int, int));
void ShellSort(int(*compare)(int, int));
void BubbleSort(int(*compare)(int, int));
void DoubleBubbleSort(int(*compare)(int, int));
void QuickSort(int(*compare)(int, int));
void SelectSort(int(*compare)(int, int));
void HeapSort();
void MergeSort(int(*compare)(int, int));
void RadixSort();
void GoblinSort(int(*compare)(int, int));
void CountSort(int(*compare)(int, int));
private:
int SortQuickPartition(int(*compare)(int, int), int low, int high);
void QuickSortRecursion(int(*compare)(int, int),int low,int high);
void MergeSortRecursion(int(*compare)(int, int),int low, int high);
void Merge(int(*compare)(int, int),int low, int mid, int high);
static int GetDigit(int number, int position);
};