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

Class bb

code/data-structures/kd_tree.cpp:21–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19 }
20 return false; } };
21 struct bb {
22 pt from, to;
23 bb(pt _from, pt _to) : from(_from), to(_to) {}
24 double dist(const pt &p) {
25 double sum = 0.0;
26 rep(i,0,K) {
27 if (p.coord[i] < from.coord[i])
28 sum += pow(from.coord[i] - p.coord[i], 2.0);
29 else if (p.coord[i] > to.coord[i])
30 sum += pow(p.coord[i] - to.coord[i], 2.0);
31 }
32 return sqrt(sum); }
33 bb bound(double l, int c, bool left) {
34 pt nf(from.coord), nt(to.coord);
35 if (left) nt.coord[c] = min(nt.coord[c], l);
36 else nf.coord[c] = max(nf.coord[c], l);
37 return bb(nf, nt); } };
38 struct node {
39 pt p; node *l, *r;
40 node(pt _p, node *_l, node *_r)

Callers 2

boundMethod · 0.85
nearest_neighbourMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected