diff --git a/include/aoc/Lines.hpp b/include/aoc/Lines.hpp
new file mode 100644
index 0000000..38fe8b8
--- /dev/null
+++ b/include/aoc/Lines.hpp
@@ -0,0 +1,37 @@
+// Solutions to the Advent Of Code 2024.
+// Copyright (C) 2024-2025 Stefan Müller
+//
+// This program is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program. If not, see .
+
+#pragma once
+
+#include
+#include
+#include
+
+#include
+
+///
+/// A vector of strings of the same length, with methods to treat it as a rectangular, two-dimensional map of char and
+/// access points on it.
+///
+class Lines
+ : public std::vector
+{
+public:
+ bool isInBounds(const Point2& point) const;
+ char getCharAt(const Point2& point) const;
+ void setCharAt(const Point2& point, const char value);
+};
+
+std::ostream& operator<<(std::ostream& os, const Lines& lines);
diff --git a/include/aoc/LinesSolver.hpp b/include/aoc/LinesSolver.hpp
index 21a2f0e..a06b36d 100644
--- a/include/aoc/LinesSolver.hpp
+++ b/include/aoc/LinesSolver.hpp
@@ -17,6 +17,7 @@
#include
+#include
#include
#include
@@ -27,7 +28,7 @@ class LinesSolver
LinesSolver(const int inputFileNameSuffix = 0);
virtual void processDataLine(const std::string& line) override;
protected:
- std::vector lines{};
+ Lines lines{};
bool isInBounds(const Point2& point) const;
char getCharAt(const Point2& point) const;
void setCharAt(const Point2& point, const char value);
diff --git a/src/Lines.cpp b/src/Lines.cpp
new file mode 100644
index 0000000..433264d
--- /dev/null
+++ b/src/Lines.cpp
@@ -0,0 +1,43 @@
+// Solutions to the Advent Of Code 2024.
+// Copyright (C) 2024-2025 Stefan Müller
+//
+// This program is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program. If not, see .
+
+#include
+
+#include
+
+bool Lines::isInBounds(const Point2& point) const
+{
+ return 0 <= point.y && point.y < size() &&
+ 0 <= point.x && point.x < at(point.y).size();
+}
+
+char Lines::getCharAt(const Point2& point) const
+{
+ return at(point.y)[point.x];
+}
+
+void Lines::setCharAt(const Point2& point, const char value)
+{
+ at(point.y)[point.x] = value;
+}
+
+std::ostream& operator<<(std::ostream& os, const Lines& lines)
+{
+ for (const auto& line : lines)
+ {
+ os << line << std::endl;
+ }
+ return os;
+}
diff --git a/src/LinesSolver.cpp b/src/LinesSolver.cpp
index ee42de4..1fb2fe1 100644
--- a/src/LinesSolver.cpp
+++ b/src/LinesSolver.cpp
@@ -27,16 +27,15 @@ void LinesSolver::processDataLine(const std::string& line)
bool LinesSolver::isInBounds(const Point2& point) const
{
- return 0 <= point.y && point.y < lines.size() &&
- 0 <= point.x && point.x < lines[point.y].size();
+ return lines.isInBounds(point);
}
char LinesSolver::getCharAt(const Point2& point) const
{
- return lines[point.y][point.x];
+ return lines.getCharAt(point);
}
void LinesSolver::setCharAt(const Point2& point, const char value)
{
- lines[point.y][point.x] = value;
+ lines.setCharAt(point, value);
}