diff options
author | hop311 <hop3114@gmail.com> | 2024-07-17 00:57:50 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-07-17 00:58:05 +0200 |
commit | f83e869def6608f64606aead24ad1cfbb6f5c72a (patch) | |
tree | fae6a1086f3ae698c4fb3f18340c5ed5f580c889 /src/openvic-simulation/map/ProvinceInstance.cpp | |
parent | e8a3b33f13ebdf3a388b4996308b4db9763dc375 (diff) |
Add IndexedMap and use in low key count, high value density casesindexed-map
Diffstat (limited to 'src/openvic-simulation/map/ProvinceInstance.cpp')
-rw-r--r-- | src/openvic-simulation/map/ProvinceInstance.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/openvic-simulation/map/ProvinceInstance.cpp b/src/openvic-simulation/map/ProvinceInstance.cpp index 8bb5345..1792fe0 100644 --- a/src/openvic-simulation/map/ProvinceInstance.cpp +++ b/src/openvic-simulation/map/ProvinceInstance.cpp @@ -7,8 +7,10 @@ using namespace OpenVic; -ProvinceInstance::ProvinceInstance(ProvinceDefinition const& new_province_definition) - : HasIdentifierAndColour { new_province_definition }, +ProvinceInstance::ProvinceInstance( + ProvinceDefinition const& new_province_definition, decltype(pop_type_distribution)::keys_t const& pop_type_keys, + decltype(ideology_distribution)::keys_t const& ideology_keys +) : HasIdentifierAndColour { new_province_definition }, province_definition { new_province_definition }, terrain_type { new_province_definition.get_default_terrain_type() }, life_rating { 0 }, @@ -25,8 +27,8 @@ ProvinceInstance::ProvinceInstance(ProvinceDefinition const& new_province_defini navies {}, pops {}, total_population { 0 }, - pop_type_distribution {}, - ideology_distribution {}, + pop_type_distribution { &pop_type_keys }, + ideology_distribution { &ideology_keys }, culture_distribution {}, religion_distribution {} {} @@ -58,7 +60,7 @@ bool ProvinceInstance::add_pop_vec(std::vector<PopBase> const& pop_vec) { if (!province_definition.is_water()) { reserve_more(pops, pop_vec.size()); for (PopBase const& pop : pop_vec) { - _add_pop(Pop { pop }); + _add_pop(Pop { pop, *ideology_distribution.get_keys() }); } return true; } else { @@ -82,7 +84,7 @@ void ProvinceInstance::_update_pops() { religion_distribution.clear(); for (Pop const& pop : pops) { total_population += pop.get_size(); - pop_type_distribution[&pop.get_type()] += pop.get_size(); + pop_type_distribution[pop.get_type()] += pop.get_size(); ideology_distribution += pop.get_ideologies(); culture_distribution[&pop.get_culture()] += pop.get_size(); religion_distribution[&pop.get_religion()] += pop.get_size(); @@ -214,10 +216,8 @@ bool ProvinceInstance::apply_history_to_province(ProvinceHistoryEntry const* ent return ret; } -void ProvinceInstance::setup_pop_test_values( - IdeologyManager const& ideology_manager, IssueManager const& issue_manager, CountryDefinition const& country -) { +void ProvinceInstance::setup_pop_test_values(IssueManager const& issue_manager) { for (Pop& pop : pops) { - pop.setup_pop_test_values(ideology_manager, issue_manager, country); + pop.setup_pop_test_values(issue_manager); } } |