-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
91 lines (74 loc) · 2.59 KB
/
main.cpp
File metadata and controls
91 lines (74 loc) · 2.59 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <iostream>
#include <vector>
using namespace std;
#include ".\head\ve.hh"
#include "head\insertSort.hh"
#include "head\quickSort.hh"
#include "head\kthQuantiles.hh"
/*******************************************************************************************************************/
struct singleListNode {
singleListNode(int k) : key(k), np(NULL)/* , prev(0), next(0) */{
}
singleListNode* np;
int key;
};
class doubleList{
private:
singleListNode* head;
singleListNode* tail;
public:
doubleList() : head(nullptr), tail(nullptr){
}
void insert(singleListNode* node);
inline singleListNode* getHead(){ return head; }
inline singleListNode* getTail() { return tail; }
inline void setHead(singleListNode* node) { head = node; }
inline void setTail(singleListNode* node) { tail = node; }
};
void doubleList::insert(singleListNode* node){
if (head) {
head->np = reinterpret_cast<singleListNode*>(reinterpret_cast<uint64_t>(head->np) ^ reinterpret_cast<uint64_t>(node));
node->np = reinterpret_cast<singleListNode*>(0 ^ reinterpret_cast<uint64_t>(head));
head = node;
}
else {
head = node;
}
}
int main(){
//
// cout << "test" << endl;
// vector<int> A{3, 5, 9, 2, 1, 4, 7, 8, 6, 0, 10, 12, 11, 13, 14, 15, 17, 18, 16, 19};
// insertSort(A, 5, 9);
// int a = select(A, 0, 14, 13);
// int mid = median(A, 0, 14);
// quickSort(A, 0, 9);
// int pivotPos = partition(A, 0, 12, 5);
// bestQuickSort(A, 0, 12);
// vector<int> A{3, 5, 9, 2, 1, 4, 7, 8, 6, 0, 10, 12, 11, 13, 14, 15, 17, 18, 16, 19};
// vector<int> kLine = kthQuantiles(A, 0, 19, 4);
// vector<int> A{3, 5, 9, 2, 1, 4, 7, 8, 6, 10, 12, 11, 13, 14, 15, 17, 18, 16, 19};
// int res = median(A, 0, 15);
// auto res = findTheNearestKnums(A, 0, 14, 4);
// vector<int> X{1, 3, 5, 7, 9};
// vector<int> Y{2, 4, 6, 8, 10};
// int median = twoArrayMedian(X, 0, 4, Y, 0, 4);
// vector<pair<int, float>> A{
// {5,0.0333}, {6,0.0417}, {7,0.05}, {8,0.0583},
// {1,0.0}, {2,0.0083}, {3,0.0167}, {4,0.025},
// {13,0.1}, {14,0.1083}, {15,0.1167}, {16,0.125},
// {9,0.0667}, {10,0.075}, {11,0.0833}, {12,0.0917}
// };
// auto mid = median(A, 0, 6);
// auto res = weightedMedian(A, 0, 15, 0.5);
// print(A);
// vector<int> A{3, 5, 9, 2, 1, 4, 7, 8, 6, 10, 12, 11};
// auto res = modifiedSelect(A, 0, 10, 4);
//
auto elem0 = new singleListNode(0);
auto elem1 = new singleListNode(1);
auto elem2 = new singleListNode(2);
doubleList dL;
dL.insert(elem0);
return 0;
}