From f83e869def6608f64606aead24ad1cfbb6f5c72a Mon Sep 17 00:00:00 2001 From: hop311 Date: Tue, 16 Jul 2024 23:57:50 +0100 Subject: Add IndexedMap and use in low key count, high value density cases --- src/openvic-simulation/history/CountryHistory.hpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/openvic-simulation/history/CountryHistory.hpp') diff --git a/src/openvic-simulation/history/CountryHistory.hpp b/src/openvic-simulation/history/CountryHistory.hpp index 0de76c6..c74841d 100644 --- a/src/openvic-simulation/history/CountryHistory.hpp +++ b/src/openvic-simulation/history/CountryHistory.hpp @@ -1,11 +1,11 @@ #pragma once #include -#include #include "openvic-simulation/history/HistoryMap.hpp" #include "openvic-simulation/types/Date.hpp" #include "openvic-simulation/types/fixed_point/FixedPointMap.hpp" +#include "openvic-simulation/types/IndexedMap.hpp" #include "openvic-simulation/types/OrderedContainers.hpp" namespace OpenVic { @@ -36,7 +36,7 @@ namespace OpenVic { std::optional PROPERTY(religion); std::optional PROPERTY(ruling_party); std::optional PROPERTY(last_election); - fixed_point_map_t PROPERTY(upper_house); + IndexedMap PROPERTY(upper_house); std::optional PROPERTY(capital); std::optional PROPERTY(government_type); std::optional PROPERTY(plurality); @@ -57,10 +57,13 @@ namespace OpenVic { std::optional PROPERTY(colonial_points); string_set_t PROPERTY(country_flags); string_set_t PROPERTY(global_flags); - ordered_map PROPERTY(government_flag_overrides); + IndexedMap PROPERTY(government_flag_overrides); ordered_set PROPERTY(decisions); - CountryHistoryEntry(CountryDefinition const& new_country, Date new_date); + CountryHistoryEntry( + CountryDefinition const& new_country, Date new_date, decltype(upper_house)::keys_t const& ideology_keys, + decltype(government_flag_overrides)::keys_t const& government_type_keys + ); }; class Dataloader; @@ -72,9 +75,14 @@ namespace OpenVic { private: CountryDefinition const& PROPERTY(country); + decltype(CountryHistoryEntry::upper_house)::keys_t const& PROPERTY(ideology_keys); + decltype(CountryHistoryEntry::government_flag_overrides)::keys_t const& PROPERTY(government_type_keys); protected: - CountryHistoryMap(CountryDefinition const& new_country); + CountryHistoryMap( + CountryDefinition const& new_country, decltype(ideology_keys) new_ideology_keys, + decltype(government_type_keys) new_government_type_keys + ); std::unique_ptr _make_entry(Date date) const override; bool _load_history_entry( @@ -99,7 +107,8 @@ namespace OpenVic { bool load_country_history_file( DefinitionManager& definition_manager, Dataloader const& dataloader, CountryDefinition const& country, - ast::NodeCPtr root + decltype(CountryHistoryMap::ideology_keys) ideology_keys, + decltype(CountryHistoryMap::government_type_keys) government_type_keys, ast::NodeCPtr root ); }; -- cgit v1.2.3-56-ga3b1