Allow most libraries to reserve capacity for their database.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
db2eb0c3fa
commit
4d3dc28606
|
@ -11,7 +11,8 @@ namespace CreatureLib::Library {
|
|||
std::unordered_map<std::string, const AttackData*> _attacks;
|
||||
|
||||
public:
|
||||
AttackLibrary() = default;
|
||||
AttackLibrary(size_t initialCapacity = 32)
|
||||
: _attacks(std::unordered_map<std::string, const AttackData*>(initialCapacity)){};
|
||||
|
||||
~AttackLibrary() {
|
||||
for (auto attack : _attacks) {
|
||||
|
|
|
@ -12,6 +12,9 @@ namespace CreatureLib::Library {
|
|||
std::unordered_map<std::string, GrowthRate*> _growthRates;
|
||||
|
||||
public:
|
||||
GrowthRateLibrary(size_t initialCapacity = 10)
|
||||
: _growthRates(std::unordered_map<std::string, GrowthRate*>(initialCapacity)) {}
|
||||
|
||||
~GrowthRateLibrary() {
|
||||
for (auto gr : _growthRates) {
|
||||
delete gr.second;
|
||||
|
|
|
@ -11,7 +11,8 @@ namespace CreatureLib::Library {
|
|||
std::unordered_map<std::string, const Item*> _items;
|
||||
|
||||
public:
|
||||
ItemLibrary() = default;
|
||||
ItemLibrary(size_t initialCapacity = 32)
|
||||
: _items(std::unordered_map<std::string, const Item*>(initialCapacity)){};
|
||||
~ItemLibrary() { _items.clear(); }
|
||||
|
||||
[[nodiscard]] const Item* GetItem(const std::string& name) const;
|
||||
|
|
|
@ -11,7 +11,8 @@ namespace CreatureLib::Library {
|
|||
std::unordered_map<std::string, const CreatureSpecies*> _species;
|
||||
|
||||
public:
|
||||
SpeciesLibrary() = default;
|
||||
SpeciesLibrary(size_t initialCapacity = 32)
|
||||
: _species(std::unordered_map<std::string, const CreatureSpecies*>(initialCapacity)){};
|
||||
|
||||
~SpeciesLibrary() {
|
||||
for (auto s : _species)
|
||||
|
|
|
@ -10,6 +10,8 @@ namespace CreatureLib::Library {
|
|||
std::vector<std::vector<float>> _effectiveness;
|
||||
|
||||
public:
|
||||
TypeLibrary(size_t initialCapacity = 20) : _types(std::unordered_map<std::string, uint8_t>(initialCapacity)) {}
|
||||
|
||||
uint8_t GetTypeId(const std::string& s) const;
|
||||
float GetSingleEffectiveness(uint8_t attacking, uint8_t defensive) const;
|
||||
float GetEffectiveness(uint8_t attacking, const std::vector<uint8_t>& defensive) const;
|
||||
|
|
Loading…
Reference in New Issue