-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisks.h
62 lines (48 loc) · 1.4 KB
/
disks.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
#ifndef DISKS_DISKS_H
#define DISKS_DISKS_H
#include <vector>
#include <deque>
#include <ostream>
#include <algorithm>
#include <functional>
using namespace std;
class Point {
public:
int x{}, y{};
Point() {
this->x = 0;
this->y = 0;
}
Point(int x, int y) {
this->x = x;
this->y = y;
}
friend ostream& operator<<(ostream& os, const Point& p);
bool operator==(const Point &rhs) const;
bool operator!=(const Point &rhs) const;
bool operator<(const Point &rhs) const;
bool operator>(const Point &rhs) const;
bool operator<=(const Point &rhs) const;
bool operator>=(const Point &rhs) const;
};
deque<Point> getConvexHull(deque<Point>& points);
std::vector<Point> getConvexHull(std::vector<Point>& points);
// TODO: target complexity: O(r*n) min, O(r*n log(h)) max, r -> h/2
template <typename T>
size_t countDisks(T& set) {
size_t count = 0;
while (set.size() > 2) {
auto exclude = getConvexHull(set);
// FIXME: Damn, this ruins everything!
for (auto& elem : exclude)
erase(set, elem);
++count;
}
return count;
}
//template<typename return_value, typename parameter>
//using func = std::function<return_value(parameter)>;
//
//template<typename return_value, typename parameterT>
//size_t count_disks(func<return_value, parameterT> f, parameterT& set);
#endif //DISKS_DISKS_H