Add EnumIndexedVector::indices().
authorCarl Hetherington <cth@carlh.net>
Sun, 6 Nov 2022 20:50:54 +0000 (21:50 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 22 Dec 2022 23:12:00 +0000 (00:12 +0100)
src/lib/enum_indexed_vector.h

index 0187daba2f0a93389d6448d345f61cf4492b1762..ee34575ea3bd82758c6e1fdde8131a36dcef5ffb 100644 (file)
@@ -70,8 +70,18 @@ public:
                return _data.end();
        }
 
+       std::vector<Enum> indices() const {
+               if (_indices.empty()) {
+                       for (int i = 0; i < static_cast<int>(Enum::COUNT); ++i) {
+                               _indices.push_back(static_cast<Enum>(i));
+                       }
+               }
+               return _indices;
+       }
+
 private:
        std::vector<Type> _data;
+       mutable std::vector<Enum> _indices;
 };