From ef7920843808f9e181514914fe6e2af146ca03cf Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Mon, 17 Oct 2022 22:22:38 +0300 Subject: [PATCH] refactor: map::array_t now extends std::vector, instead of shelling it --- include/utils/data.hh | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/include/utils/data.hh b/include/utils/data.hh index a5ed6d2..4e13f36 100644 --- a/include/utils/data.hh +++ b/include/utils/data.hh @@ -78,14 +78,14 @@ namespace ppc::data { private: std::unordered_map values; public: - value_t &operator [](std::string name){ + value_t &operator[](std::string name){ auto res = values.find(name); if (res == values.end()) { res = values.emplace(name, value_t()).first; } return res->second; } - const value_t &operator [](std::string name) const { + const value_t &operator[](std::string name) const { auto res = values.find(name); if (res == values.end()) throw "The map doesn't contain a key '" + name + "'."; return res->second; @@ -108,25 +108,5 @@ namespace ppc::data { } }; - class array_t { - private: - std::vector values; - public: - value_t &operator [](std::size_t i) { return values[i]; } - const value_t &operator [](std::size_t i) const { return values[i]; } - - auto begin() const { return values.begin(); } - auto end() const { return values.end(); } - - void push(const value_t &val) { values.push_back(val); } - void insert(const value_t &val, std::size_t i = 0) { values.insert(begin() + i, val); } - void pop() { values.pop_back(); } - void remove(std::size_t i = 0) { values.erase(begin() + i); } - - std::size_t size() const { return values.size(); } - - array_t() { } - array_t(const std::vector &val): values(val) { } - array_t(std::initializer_list val): values(val) { } - }; + class array_t : public std::vector { }; } \ No newline at end of file