From 0b72b7efdc799f2deaf68b6c71e189d7b3bde458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20M=C3=BCller?= Date: Tue, 21 Jan 2025 14:02:10 +0100 Subject: [PATCH] Remove raw array use from PrintQueue --- include/aoc/PrintQueue.hpp | 7 +++++-- src/PrintQueue.cpp | 16 +++------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/include/aoc/PrintQueue.hpp b/include/aoc/PrintQueue.hpp index db1cc39..91811a7 100644 --- a/include/aoc/PrintQueue.hpp +++ b/include/aoc/PrintQueue.hpp @@ -15,6 +15,9 @@ #pragma once +#include + +#include #include class PrintQueue @@ -31,8 +34,8 @@ class PrintQueue static const int maxPageNo_{ 99 }; bool isProcessingOrderingRules_; int pageNoMapIndex_; - int pageNoMap_[maxPageNo_ + 1]; - bool orderingRules_[nPages_][nPages_]; + std::vector pageNoMap_; + Grid orderingRules_; size_t getMapped(const int pageNo); void processOrderingRule(const std::string& line); void processUpdatePages(const std::string& line); diff --git a/src/PrintQueue.cpp b/src/PrintQueue.cpp index 4968feb..75e4098 100644 --- a/src/PrintQueue.cpp +++ b/src/PrintQueue.cpp @@ -20,20 +20,10 @@ #include PrintQueue::PrintQueue() - : Solver{}, pageNoMapIndex_{ 0 }, isProcessingOrderingRules_{ true }, orderingRules_{} + : Solver{}, isProcessingOrderingRules_{ true }, pageNoMapIndex_{ 0 }, pageNoMap_(maxPageNo_ + 1, -1), + orderingRules_(nPages_, nPages_) { - for (size_t i = 0; i <= maxPageNo_; i++) - { - pageNoMap_[i] = -1; - } - - for (size_t i = 0; i < nPages_; i++) - { - for (size_t j = 0; j < nPages_; j++) - { - orderingRules_[i][j] = false; - } - } + orderingRules_.fill(false); } const std::string PrintQueue::getPuzzleName() const