-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathList.h
63 lines (49 loc) · 962 Bytes
/
List.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
#include <mach/mach.h>
#include <mach/mach_time.h>
#include <unistd.h>
#include <CoreServices/CoreServices.h>
enum sort_type {
SORT_BUBBLE,
SORT_SELECTION,
SORT_QUICK,
SORT_INSERTION,
SORT_MERGE,
SORT_HEAP,
SORT_SHELL
};
struct node {
node *prev;
node *next;
int number;
};
class List {
private:
node *first;
node *last;
int count;
uint64_t start_time;
node* merge_helper(node* start, int length);
void quick_helper( node* start, node* last, int nodeCount );
protected:
void sort_bubble();
void sort_selection();
void sort_quick();
void sort_insertion();
void sort_merge();
void sort_heap();
void sort_shell();
public:
List();
~List();
void insert(int number);
void insert(int number, int index);
void sort();
void sort(sort_type sorttype);
void remove(int index);
node* find(int index);
void print();
void print(int index);
int size();
void start();
void time_spend();
};