From eecf4b1e666211a13afa56f93477c55e8fd01621 Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 2 Jun 2022 19:51:54 +0200 Subject: feat: implement game of life --- src/engine/data/vector2.cpp | 7 +++++++ src/engine/data/vector2.hpp | 2 ++ 2 files changed, 9 insertions(+) (limited to 'src/engine/data') diff --git a/src/engine/data/vector2.cpp b/src/engine/data/vector2.cpp index 0f203d0..cb81947 100644 --- a/src/engine/data/vector2.cpp +++ b/src/engine/data/vector2.cpp @@ -2,6 +2,8 @@ #include "util/hash.hpp" +#include + auto Vector2::get_x() const noexcept -> Vector2::Value { return _x; @@ -79,6 +81,11 @@ auto Vector2::operator==(const Vector2 &rhs) const noexcept -> bool return _x == rhs._x && _y == rhs._y; } +auto Vector2::operator<(const Vector2 &rhs) const noexcept -> bool +{ + return std::tie(_x, _y) < std::tie(rhs._x, rhs._y); +} + auto Vector2Hasher::operator()(const Vector2 &vector2) const noexcept -> std::size_t { std::size_t result_hash = 0; diff --git a/src/engine/data/vector2.hpp b/src/engine/data/vector2.hpp index 620b41c..96ebf87 100644 --- a/src/engine/data/vector2.hpp +++ b/src/engine/data/vector2.hpp @@ -43,6 +43,8 @@ public: auto operator==(const Vector2 &rhs) const noexcept -> bool; + auto operator<(const Vector2 &rhs) const noexcept -> bool; + /** * Returns Vector2({.x = 0, .y = 1}) */ -- cgit v1.2.3-18-g5258