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

Method _nn

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

Source from the content-addressed store, hash-verified

75 _nn(p, root, bb(from, to), mn, resp, 0, allow_same);
76 return make_pair(resp, !std::isinf(mn)); }
77 void _nn(const pt &p, node *n, bb b,
78 double &mn, pt &resp, int c, bool same) {
79 if (!n || b.dist(p) > mn) return;
80 bool l1 = true, l2 = false;
81 if ((same || p.dist(n->p) > EPS) && p.dist(n->p) < mn)
82 mn = p.dist(resp = n->p);
83 node *n1 = n->l, *n2 = n->r;
84 rep(i,0,2) {
85 if (i == 1 || cmp(c)(n->p, p)) swap(n1,n2),swap(l1,l2);
86 _nn(p, n1, b.bound(n->p.coord[c], c, l1), mn,
87 resp, INC(c), same); } } };
88// vim: cc=60 ts=2 sts=2 sw=2:

Callers

nothing calls this directly

Calls 3

boundMethod · 0.80
cmpClass · 0.70
distMethod · 0.45

Tested by

no test coverage detected