MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / point

Class point

code/data-structures/kd_tree.test.cpp:4–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2struct naive_kd_tree {
3
4 struct point {
5 double coord[K];
6 point() {}
7 point(double c[K]) {
8 for (int i = 0; i < K; i++)
9 coord[i] = c[i];
10 }
11
12 double dist_to(const point &other) const {
13 double sum = 0.0;
14 for (int i = 0; i < K; i++)
15 sum += pow(coord[i] - other.coord[i], 2.0);
16 return sqrt(sum);
17 }
18
19 bool operator <(const point &other) const {
20 for (int i = 0; i < K; i++)
21 if (abs(coord[i] - other.coord[i]) > EPS)
22 return coord[i] < other.coord[i];
23 return false;
24 }
25 };
26
27 set<point> pts;
28

Callers 1

testFunction · 0.70

Calls

no outgoing calls

Tested by 1

testFunction · 0.56