From 2df2b58d3ed28d56f367667382f56773405e760b Mon Sep 17 00:00:00 2001 From: joshvera Date: Wed, 2 Dec 2015 17:28:52 -0500 Subject: [PATCH] Move point helpers elsewhere --- spec/runtime/helpers/point_helpers.cc | 24 ++++++++++++++++++++++++ spec/runtime/helpers/point_helpers.h | 8 ++++++++ 2 files changed, 32 insertions(+) create mode 100644 spec/runtime/helpers/point_helpers.cc create mode 100644 spec/runtime/helpers/point_helpers.h 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);