Bring Library class in line with style lines.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2020-06-20 18:50:55 +02:00
parent add77325a4
commit 14458ec30c
21 changed files with 133 additions and 166 deletions

View File

@@ -20,7 +20,7 @@ namespace CreatureLib::Library {
public:
BaseLibrary(size_t initialCapacity = 32) : _values(initialCapacity), _listValues(initialCapacity) {}
virtual ~BaseLibrary() { _values.Clear(); }
virtual ~BaseLibrary() noexcept { _values.Clear(); }
inline void Insert(const ArbUt::CaseInsensitiveConstString& key, const T* value) {
AssertNotNull(value)
@@ -33,21 +33,21 @@ namespace CreatureLib::Library {
_listValues.Append(hashedKey);
}
inline void Delete(const ArbUt::CaseInsensitiveConstString& key) {
inline void Delete(const ArbUt::CaseInsensitiveConstString& key) noexcept {
_values.erase(key.GetHash());
auto k = _listValues.IndexOf(key);
_listValues.Remove(k);
}
inline void Delete(uint32_t hashedKey) {
inline void Delete(uint32_t hashedKey) noexcept {
_values.Remove(hashedKey);
auto k = _listValues.IndexOf(hashedKey);
_listValues.Remove(k);
}
bool TryGet(const ArbUt::CaseInsensitiveConstString& name, ArbUt::BorrowedPtr<const T>& out) const {
bool TryGet(const ArbUt::CaseInsensitiveConstString& name, ArbUt::BorrowedPtr<const T>& out) const noexcept {
return TryGet(name.GetHash(), out);
}
bool TryGet(uint32_t hashedKey, ArbUt::BorrowedPtr<const T>& out) const {
bool TryGet(uint32_t hashedKey, ArbUt::BorrowedPtr<const T>& out) const noexcept {
auto find = _values.GetStdMap().find(hashedKey);
if (find == _values.GetStdMap().end())
return false;
@@ -67,17 +67,18 @@ namespace CreatureLib::Library {
return Get(name);
}
[[nodiscard]] inline ArbUt::BorrowedPtr<const T> operator[](uint32_t hashedKey) const { return Get(hashedKey); }
[[nodiscard]] inline const ArbUt::Dictionary<uint32_t, const std::unique_ptr<const T>>& GetIterator() const {
[[nodiscard]] inline const ArbUt::Dictionary<uint32_t, const std::unique_ptr<const T>>&
GetIterator() const noexcept {
return _values;
}
[[nodiscard]] size_t GetCount() const { return _values.Count(); }
[[nodiscard]] size_t GetCount() const noexcept { return _values.Count(); }
inline ArbUt::BorrowedPtr<const T> GetRandomValue(ArbUt::Random rand = ArbUt::Random()) const {
inline ArbUt::BorrowedPtr<const T> GetRandomValue(ArbUt::Random rand = ArbUt::Random()) const noexcept {
auto i = rand.Get(_listValues.Count());
return _values[_listValues[i]];
}
inline ArbUt::BorrowedPtr<const T> GetRandomValue(ArbUt::Random* rand) const {
inline ArbUt::BorrowedPtr<const T> GetRandomValue(ArbUt::Random* rand) const noexcept {
auto i = rand->Get(_listValues.Count());
return _values[_listValues[i]];
}