diff options
Diffstat (limited to 'gfx/point.h')
-rw-r--r-- | gfx/point.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gfx/point.h b/gfx/point.h index e93dc0c..5c6cb72 100644 --- a/gfx/point.h +++ b/gfx/point.h @@ -73,6 +73,16 @@ class Point { return !(*this == rhs); } + // A point is less than another point if its y-value is closer + // to the origin. If the y-values are the same, then point with + // the x-value closer to the origin is considered less than the + // other. + // This comparison is required to use Points in sets, or sorted + // vectors. + bool operator<(const Point& rhs) const { + return (y_ == rhs.y_) ? (x_ < rhs.x_) : (y_ < rhs.y_); + } + #if defined(OS_WIN) POINT ToPOINT() const; #elif defined(OS_MACOSX) |