summaryrefslogtreecommitdiff
path: root/Libraries/LibVT/Position.h
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries/LibVT/Position.h')
-rw-r--r--Libraries/LibVT/Position.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/Libraries/LibVT/Position.h b/Libraries/LibVT/Position.h
new file mode 100644
index 0000000000..d6766029f7
--- /dev/null
+++ b/Libraries/LibVT/Position.h
@@ -0,0 +1,48 @@
+#pragma once
+
+namespace VT {
+
+class Position {
+public:
+ Position() {}
+ Position(int row, int column)
+ : m_row(row)
+ , m_column(column)
+ {
+ }
+
+ bool is_valid() const { return m_row >= 0 && m_column >= 0; }
+ int row() const { return m_row; }
+ int column() const { return m_column; }
+
+ bool operator<(const Position& other) const
+ {
+ return m_row < other.m_row || (m_row == other.m_row && m_column < other.m_column);
+ }
+
+ bool operator<=(const Position& other) const
+ {
+ return *this < other || *this == other;
+ }
+
+ bool operator>=(const Position& other) const
+ {
+ return !(*this < other);
+ }
+
+ bool operator==(const Position& other) const
+ {
+ return m_row == other.m_row && m_column == other.m_column;
+ }
+
+ bool operator!=(const Position& other) const
+ {
+ return !(*this == other);
+ }
+
+private:
+ int m_row { -1 };
+ int m_column { -1 };
+};
+
+}