From 2c5063b073d4c1acc64350cf63ab0bacc9763d15 Mon Sep 17 00:00:00 2001 From: fluffymormegil Date: Thu, 21 Oct 2010 23:03:26 +0100 Subject: [PATCH] Comparator methods for basic_coord / basic_offset --- include/libmormegil/Coord.hh | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/include/libmormegil/Coord.hh b/include/libmormegil/Coord.hh index aefcd60..052323e 100644 --- a/include/libmormegil/Coord.hh +++ b/include/libmormegil/Coord.hh @@ -32,6 +32,7 @@ #ifndef libmormegil_Coord_hh #define libmormegil_Coord_hh #include +#include #ifndef libmormegil_abs_hh #include @@ -70,6 +71,21 @@ namespace libmormegil return *this; } + bool operator <(const basic_offset& right) const + { + return (y < right.y) || ((y == right.y) && (x < right.x)); + } + + bool operator ==(const basic_offset& right) const + { + return (y == right.y) && (x == right.x); + } + + bool operator >(const basic_offset& right) const + { + return (y > right.y) || ((y == right.y) && (x > right.x)); + } + int length_taxi() { return abs(y) + abs(x); } int lengthsq() { return y * y + x * x; } int length_inf() { return std::min(abs(y), abs(x)); } @@ -104,6 +120,21 @@ namespace libmormegil basic_offset tmp = { y - right.y, x - right.x }; return tmp; } + bool operator <(const_ref right) const + { + return (y < right.y) || ((y == right.y) && (x < right.x)); + } + + bool operator ==(const_ref right) const + { + return (y == right.y) && (x == right.x); + } + + bool operator >(const_ref right) const + { + return (y > right.y) || ((y == right.y) && (x > right.x)); + } + int dist_taxi(const_ref right) const { return abs(y - right.y) + abs(x - right.x); @@ -131,8 +162,10 @@ namespace libmormegil } }; - typedef basic_offset Offset; - typedef basic_coord Coord; + typedef basic_offset Offset; + typedef basic_coord Coord; + typedef basic_offset Offset64; + typedef basic_coord Coord64; } #endif // libmormegil_Coord_hh -- 2.11.0