Supports iterating over BaseLibrary.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-07-04 17:18:24 +02:00
parent 61bf868583
commit 47515399fe
2 changed files with 32 additions and 0 deletions

View File

@@ -71,6 +71,19 @@ namespace CreatureLib::Library {
return _values;
}
using const_iterator = typename std::unordered_map<uint32_t, ArbUt::BorrowedPtr<const T>>::const_iterator;
inline const_iterator begin() const {
return reinterpret_cast<const std::unordered_map<uint32_t, ArbUt::BorrowedPtr<const T>>&>(
_values.GetStdMap())
.begin();
}
inline const_iterator end() const {
return reinterpret_cast<const std::unordered_map<uint32_t, ArbUt::BorrowedPtr<const T>>&>(
_values.GetStdMap())
.end();
}
[[nodiscard]] size_t GetCount() const noexcept { return _values.Count(); }
inline ArbUt::BorrowedPtr<const T> GetRandomValue(ArbUt::Random rand = ArbUt::Random()) const noexcept {