Update to newer Arbutils version.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-05-26 18:31:06 +02:00
parent d746b3ecce
commit 25f65eb47b
68 changed files with 334 additions and 354 deletions

View File

@@ -5,7 +5,7 @@
#include <Arbutils/Collections/Dictionary.hpp>
#include <Arbutils/Collections/List.hpp>
#include <Arbutils/ConstString.hpp>
#include <Arbutils/Memory/borrowed_ptr.hpp>
#include <Arbutils/Memory/BorrowedPtr.hpp>
#include <Arbutils/Random.hpp>
#include <algorithm>
#include <memory>
@@ -13,8 +13,8 @@
namespace CreatureLib::Library {
template <class T> class BaseLibrary {
Arbutils::Collections::Dictionary<uint32_t, std::unique_ptr<const T>> _values;
Arbutils::Collections::List<uint32_t> _listValues;
ArbUt::Dictionary<uint32_t, std::unique_ptr<const T>> _values;
ArbUt::List<uint32_t> _listValues;
size_t _index;
public:
@@ -22,7 +22,7 @@ namespace CreatureLib::Library {
virtual ~BaseLibrary() { _values.Clear(); }
inline void Insert(const Arbutils::CaseInsensitiveConstString& key, const T* value) {
inline void Insert(const ArbUt::CaseInsensitiveConstString& key, const T* value) {
AssertNotNull(value)
_values.GetStdMap().insert({key.GetHash(), std::unique_ptr<const T>(value)});
_listValues.Append(key);
@@ -33,7 +33,7 @@ namespace CreatureLib::Library {
_listValues.Append(hashedKey);
}
inline void Delete(const Arbutils::CaseInsensitiveConstString& key) {
inline void Delete(const ArbUt::CaseInsensitiveConstString& key) {
_values.erase(key.GetHash());
auto k = _listValues.IndexOf(key);
_listValues.Remove(k);
@@ -44,10 +44,10 @@ namespace CreatureLib::Library {
_listValues.Remove(k);
}
bool TryGet(const Arbutils::CaseInsensitiveConstString& name, borrowed_ptr<const T>& out) const {
bool TryGet(const ArbUt::CaseInsensitiveConstString& name, ArbUt::BorrowedPtr<const T>& out) const {
return TryGet(name.GetHash(), out);
}
bool TryGet(uint32_t hashedKey, borrowed_ptr<const T>& out) const {
bool TryGet(uint32_t hashedKey, ArbUt::BorrowedPtr<const T>& out) const {
auto find = _values.GetStdMap().find(hashedKey);
if (find == _values.GetStdMap().end())
return false;
@@ -55,27 +55,29 @@ namespace CreatureLib::Library {
return true;
}
[[nodiscard]] inline borrowed_ptr<const T> Get(const Arbutils::CaseInsensitiveConstString& name) const {
[[nodiscard]] inline ArbUt::BorrowedPtr<const T> Get(const ArbUt::CaseInsensitiveConstString& name) const {
return _values.Get(name.GetHash());
}
[[nodiscard]] inline borrowed_ptr<const T> Get(uint32_t hashedKey) const { return _values.Get(hashedKey); }
[[nodiscard]] inline ArbUt::BorrowedPtr<const T> Get(uint32_t hashedKey) const {
return _values.Get(hashedKey);
}
[[nodiscard]] inline borrowed_ptr<const T> operator[](const Arbutils::CaseInsensitiveConstString& name) const {
[[nodiscard]] inline ArbUt::BorrowedPtr<const T>
operator[](const ArbUt::CaseInsensitiveConstString& name) const {
return Get(name);
}
[[nodiscard]] inline borrowed_ptr<const T> operator[](uint32_t hashedKey) const { return Get(hashedKey); }
[[nodiscard]] inline const Arbutils::Collections::Dictionary<uint32_t, const std::unique_ptr<const T>>&
GetIterator() const {
[[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 {
return _values;
}
[[nodiscard]] size_t GetCount() const { return _values.Count(); }
inline borrowed_ptr<const T> GetRandomValue(Arbutils::Random rand = Arbutils::Random()) const {
inline ArbUt::BorrowedPtr<const T> GetRandomValue(ArbUt::Random rand = ArbUt::Random()) const {
auto i = rand.Get(_listValues.Count());
return _values[_listValues[i]];
}
inline borrowed_ptr<const T> GetRandomValue(Arbutils::Random* rand) const {
inline ArbUt::BorrowedPtr<const T> GetRandomValue(ArbUt::Random* rand) const {
auto i = rand->Get(_listValues.Count());
return _values[_listValues[i]];
}