From 6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6 Mon Sep 17 00:00:00 2001 From: Elizabeth Alexander Hunt Date: Thu, 2 Jul 2026 11:55:17 -0700 Subject: Init --- Homework/cs3460/gameoflife/PatternSet.cpp | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Homework/cs3460/gameoflife/PatternSet.cpp (limited to 'Homework/cs3460/gameoflife/PatternSet.cpp') diff --git a/Homework/cs3460/gameoflife/PatternSet.cpp b/Homework/cs3460/gameoflife/PatternSet.cpp new file mode 100644 index 0000000..8bb3cdf --- /dev/null +++ b/Homework/cs3460/gameoflife/PatternSet.cpp @@ -0,0 +1,42 @@ +#include "PatternSet.hpp" + +PatternSet::PatternSet(std::uint8_t width, std::uint8_t height) : + m_width(width), m_height(height) +{ +} + +PatternSet::PatternSet(const std::set> aliveCells) : + m_aliveCells(aliveCells) +{ + m_width = std::max_element( + aliveCells.begin(), aliveCells.end(), + [](const auto coord1, const auto coord2) + { + return coord1.first < coord2.first; + }) + ->first + + 1; + m_height = std::max_element( + aliveCells.begin(), aliveCells.end(), + [](const auto coord1, const auto coord2) + { + return coord1.second < coord2.second; + }) + ->second + + 1; +} + +std::uint8_t PatternSet::getSizeX() const +{ + return m_width; +} + +std::uint8_t PatternSet::getSizeY() const +{ + return m_height; +} + +bool PatternSet::getCell(std::uint8_t x, std::uint8_t y) const +{ + return m_aliveCells.contains(std::pair(x, y)); +} -- cgit v1.3