diff options
| author | pjungeblut <paul.jungeblut@gmail.com> | 2014-10-25 17:50:23 +0200 |
|---|---|---|
| committer | pjungeblut <paul.jungeblut@gmail.com> | 2014-10-25 17:50:23 +0200 |
| commit | 0b40aa3bb5c635f253d300e8e2885f751848bed8 (patch) | |
| tree | e2aacd149b7cd820338e7f826f0d05a2e7d8e572 /geometry/closestPair.cpp | |
| parent | 04703be68216170849bfe5151319ec962d3d072b (diff) | |
adding makefile
Diffstat (limited to 'geometry/closestPair.cpp')
| -rw-r--r-- | geometry/closestPair.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/geometry/closestPair.cpp b/geometry/closestPair.cpp index 10c9291..92b4551 100644 --- a/geometry/closestPair.cpp +++ b/geometry/closestPair.cpp @@ -1,15 +1,13 @@ double squaredDist(point a, point b) { - return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second); + return (a.first-b.first) * (a.first-b.first) + (a.second-b.second) * (a.second-b.second); } bool compY(point a, point b) { - if (a.second == b.second) { - return a.first < b.first; - } + if (a.second == b.second) return a.first < b.first; return a.second < b.second; } -void shortestDist(vector<point> &points) { +double shortestDist(vector<point> &points) { //check that points.size() > 1 and that ALL POINTS ARE DIFFERENT set<point, bool(*)(point, point)> status(compY); sort(points.begin(), points.end()); @@ -33,5 +31,6 @@ void shortestDist(vector<point> &points) { } status.insert(*(right++)); } - } // closest distance in sqrtOpt + } + return sqrtOpt; } |
