diff --git a/include/aoc/Point2.hpp b/include/aoc/Point2.hpp index 97d4556..d5ad5bb 100644 --- a/include/aoc/Point2.hpp +++ b/include/aoc/Point2.hpp @@ -38,6 +38,7 @@ class Point2 Point2(const int x, const int y); bool operator==(const Point2& rhs) const; bool operator!=(const Point2& rhs) const; + bool operator<(const Point2& rhs) const; Point2 operator+(const Point2& rhs) const; Point2 operator-(const Point2& rhs) const; Point2 operator*(const int rhs) const; diff --git a/src/Point2.cpp b/src/Point2.cpp index 96bd023..ce629a8 100644 --- a/src/Point2.cpp +++ b/src/Point2.cpp @@ -65,6 +65,11 @@ bool Point2::operator!=(const Point2& rhs) const return !(*this == rhs); } +bool Point2::operator<(const Point2& rhs) const +{ + return x < rhs.x || (x == rhs.x && y < rhs.y); +} + Point2 Point2::operator+(const Point2& rhs) const { return Point2(x + rhs.x, y + rhs.y);