Skip to content

Commit ad5af65

Browse files
committed
IndexedFlatMap
1 parent 54c0336 commit ad5af65

File tree

4 files changed

+1014
-6
lines changed

4 files changed

+1014
-6
lines changed

src/openvic-simulation/country/CountryInstance.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ void CountryInstance::_update_budget() {
12391239

12401240
const fixed_point_t corruption_cost_multiplier = get_corruption_cost_multiplier();
12411241
for (auto const& [pop_type, size] : pop_type_distribution) {
1242-
SharedPopTypeValues const& pop_type_values = shared_country_values.get_shared_pop_type_values()[pop_type];
1242+
SharedPopTypeValues const& pop_type_values = shared_country_values.get_shared_pop_type_values(pop_type);
12431243
projected_administration_spending_unscaled_by_slider += size * calculate_administration_salary_base(pop_type_values, corruption_cost_multiplier);
12441244
projected_education_spending_unscaled_by_slider += size * calculate_education_salary_base(pop_type_values, corruption_cost_multiplier);
12451245
projected_military_spending_unscaled_by_slider += size * calculate_military_salary_base(pop_type_values, corruption_cost_multiplier);
@@ -2039,7 +2039,7 @@ void CountryInstance::request_salaries_and_welfare_and_import_subsidies(Pop& pop
20392039
PopType const& pop_type = *pop.get_type();
20402040
const pop_size_t pop_size = pop.get_size();
20412041
const fixed_point_t corruption_cost_multiplier = get_corruption_cost_multiplier();
2042-
SharedPopTypeValues const& pop_type_values = shared_country_values.get_shared_pop_type_values()[pop_type];
2042+
SharedPopTypeValues const& pop_type_values = shared_country_values.get_shared_pop_type_values(pop_type);
20432043
ModifierEffectCache const& modifier_effect_cache = shared_country_values.get_modifier_effect_cache();
20442044

20452045
if (actual_administration_spending > fixed_point_t::_0) {
@@ -2117,7 +2117,7 @@ fixed_point_t CountryInstance::calculate_minimum_wage_base(PopType const& pop_ty
21172117

21182118
return calculate_minimum_wage_base(
21192119
shared_country_values.get_modifier_effect_cache(),
2120-
shared_country_values.get_shared_pop_type_values()[pop_type]
2120+
shared_country_values.get_shared_pop_type_values(pop_type)
21212121
);
21222122
}
21232123

src/openvic-simulation/country/SharedCountryValues.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
22

33
#include "openvic-simulation/pop/PopNeedsMacro.hpp"
4-
#include "openvic-simulation/types/IndexedMap.hpp"
4+
#include "openvic-simulation/pop/PopType.hpp"
5+
#include "openvic-simulation/types/IndexedFlatMap.hpp"
56
#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
67
#include "openvic-simulation/utility/Getters.hpp"
78

@@ -10,7 +11,6 @@ namespace OpenVic {
1011
struct GoodInstanceManager;
1112
struct ModifierEffectCache;
1213
struct PopsDefines;
13-
struct PopType;
1414

1515
struct SharedPopTypeValues {
1616
private:
@@ -35,7 +35,7 @@ namespace OpenVic {
3535
ModifierEffectCache const& PROPERTY(modifier_effect_cache);
3636
CountryDefines const& PROPERTY(country_defines);
3737
PopsDefines const& pop_defines;
38-
IndexedMap<PopType, SharedPopTypeValues> PROPERTY(shared_pop_type_values);
38+
IndexedFlatMap<PopType, SharedPopTypeValues> PROPERTY(shared_pop_type_values);
3939

4040
public:
4141
SharedCountryValues(
@@ -46,6 +46,9 @@ namespace OpenVic {
4646
);
4747
SharedCountryValues(SharedCountryValues&&) = default;
4848

49+
constexpr SharedPopTypeValues const& get_shared_pop_type_values(PopType const& pop_type) const {
50+
return shared_pop_type_values.at(pop_type);
51+
}
4952
void update_costs(GoodInstanceManager const& good_instance_manager);
5053
};
5154
}

0 commit comments

Comments
 (0)