diff options
| author | MZuenni <michi.zuendorf@gmail.com> | 2022-11-30 12:43:27 +0100 |
|---|---|---|
| committer | MZuenni <michi.zuendorf@gmail.com> | 2022-11-30 12:43:27 +0100 |
| commit | 03788f48be2634c36cd19ba25b0a851685b9c877 (patch) | |
| tree | ef430668558366afe95d958d26250361f5452666 /geometry | |
| parent | 99259d60cb345eae15211397f3199aa86ac2bceb (diff) | |
use all macro
Diffstat (limited to 'geometry')
| -rw-r--r-- | geometry/closestPair.cpp | 8 | ||||
| -rw-r--r-- | geometry/convexHull.cpp | 20 | ||||
| -rw-r--r-- | geometry/linesAndSegments.cpp | 2 |
3 files changed, 15 insertions, 15 deletions
diff --git a/geometry/closestPair.cpp b/geometry/closestPair.cpp index a7662b6..7462dc0 100644 --- a/geometry/closestPair.cpp +++ b/geometry/closestPair.cpp @@ -12,14 +12,14 @@ bool compX(pt a, pt b) { : real(a) < real(b); } -double shortestDist(vector<pt>& points) { // points.size() > 1 +double shortestDist(vector<pt>& pts) { // pts.size() > 1 set<pt, bool(*)(pt, pt)> status(compY); - sort(points.begin(), points.end(), compX); + sort(all(pts), compX); double opt = 1.0/0.0, sqrtOpt = 1.0/0.0; - auto left = points.begin(), right = points.begin(); + auto left = pts.begin(), right = pts.begin(); status.insert(*right); right++; - while (right != points.end()) { + while (right != pts.end()) { if (left != right && abs(real(*left - *right)) >= sqrtOpt) { status.erase(*left); diff --git a/geometry/convexHull.cpp b/geometry/convexHull.cpp index e988977..9245acc 100644 --- a/geometry/convexHull.cpp +++ b/geometry/convexHull.cpp @@ -1,18 +1,18 @@ -vector<pt> convexHull(vector<pt> p){ - sort(p.begin(), p.end(), [](const pt& a, const pt& b){ +vector<pt> convexHull(vector<pt> pts){ + sort(all(pts), [](const pt& a, const pt& b){ return real(a) == real(b) ? imag(a) < imag(b) : real(a) < real(b); }); - p.erase(unique(p.begin(), p.end()), p.end()); + pts.erase(unique(all(pts)), pts.end()); int k = 0; - vector<pt> h(2 * sz(p)); - for (int i = 0; i < sz(p); i++) {// Untere Hülle. - while (k > 1 && cross(h[k-2], h[k-1], p[i]) <= 0) k--; - h[k++] = p[i]; + vector<pt> h(2 * sz(pts)); + for (int i = 0; i < sz(pts); i++) {// Untere Hülle. + while (k > 1 && cross(h[k-2], h[k-1], pts[i]) <= 0) k--; + h[k++] = pts[i]; } - for (int i = sz(p)-2, t = k; i >= 0; i--) {// Obere Hülle. - while (k > t && cross(h[k-2], h[k-1], p[i]) <= 0) k--; - h[k++] = p[i]; + for (int i = sz(pts)-2, t = k; i >= 0; i--) {// Obere Hülle. + while (k > t && cross(h[k-2], h[k-1], pts[i]) <= 0) k--; + h[k++] = pts[i]; } h.resize(k); return h; diff --git a/geometry/linesAndSegments.cpp b/geometry/linesAndSegments.cpp index 6c53cee..9ed39c4 100644 --- a/geometry/linesAndSegments.cpp +++ b/geometry/linesAndSegments.cpp @@ -84,7 +84,7 @@ double distBetweenSegments(pt a, pt b, pt c, pt d) { // sortiert alle Punkte pts auf einer Linie // entsprechend der richtung dir 2d und 3d void sortLine(pt dir, vector<pt>& pts) { - sort(pts.begin(), pts.end(), [&](pt a, pt b){ + sort(all(pts), [&](pt a, pt b){ return dot(dir, a) < dot(dir, b); }); }
\ No newline at end of file |
