diff --git a/spec/runtime/helpers/point_helpers.cc b/spec/runtime/helpers/point_helpers.cc new file mode 100644 index 00000000..97a444a9 --- /dev/null +++ b/spec/runtime/helpers/point_helpers.cc @@ -0,0 +1,24 @@ +#include +#include +#include "runtime/length.h" + +using namespace std; + +bool operator==(const TSPoint &left, const TSPoint &right) { + return left.row == right.row && left.column == right.column; +} + +std::ostream &operator<<(std::ostream &stream, const TSPoint &point) { + return stream << "{" << point.row << ", " << point.column << "}"; +} + +bool operator<(const TSPoint &left, const TSPoint &right) { + if (left.row < right.row) return true; + if (left.row > right.row) return false; + + return left.column < right.column; +} + +bool operator>(const TSPoint &left, const TSPoint &right) { + return right < left; +} diff --git a/spec/runtime/helpers/point_helpers.h b/spec/runtime/helpers/point_helpers.h new file mode 100644 index 00000000..671fd4dc --- /dev/null +++ b/spec/runtime/helpers/point_helpers.h @@ -0,0 +1,8 @@ + +bool operator==(const TSPoint &left, const TSPoint &right); + +bool operator<(const TSPoint &left, const TSPoint &right); + +bool operator>(const TSPoint &left, const TSPoint &right); + +std::ostream &operator<<(std::ostream &stream, const TSPoint &point);