diff options
author | Spartan322 <Megacake1234@gmail.com> | 2023-12-25 08:42:11 +0100 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2023-12-31 20:46:26 +0100 |
commit | e1496a87178d925277aceed0ebcbab06920e15ee (patch) | |
tree | ba081f9f4d74865ab5851a2efd560745900ca81a /src/openvic-simulation/dataloader/NodeTools.hpp | |
parent | 0a425fbe05d6138b753c0e4a7c06f06695bde8af (diff) |
Add `https://github.com/Tessil/ordered-map`
Add is_specialization_of to Utility.hpp
Add OpenVic::ordered_map and OpenVic::ordered_set
Change `std::map` to `ordered_map`
Change `std::set to use `ordered_set`
Add `set_callback_pointer(tsl::ordered_set<T const*>& set)`
Add mutable_iterator to enable mutable value iterator for `tsl::ordered_map`
Add std::hash<OpenVic::Date> implementation
Enable deps/SCsub to expose dependency includes neccessary for inclusion
Diffstat (limited to 'src/openvic-simulation/dataloader/NodeTools.hpp')
-rw-r--r-- | src/openvic-simulation/dataloader/NodeTools.hpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/openvic-simulation/dataloader/NodeTools.hpp b/src/openvic-simulation/dataloader/NodeTools.hpp index c3eaf65..f3224aa 100644 --- a/src/openvic-simulation/dataloader/NodeTools.hpp +++ b/src/openvic-simulation/dataloader/NodeTools.hpp @@ -10,8 +10,11 @@ #include <openvic-dataloader/v2script/AbstractSyntaxTree.hpp> +#include <tsl/ordered_set.h> + #include "openvic-simulation/types/Colour.hpp" #include "openvic-simulation/types/Date.hpp" +#include "openvic-simulation/types/OrderedContainers.hpp" #include "openvic-simulation/types/Vector.hpp" namespace OpenVic { @@ -20,10 +23,10 @@ namespace OpenVic { /* Template for map from strings to Ts, in which string_views can be * searched for without needing to be copied into a string */ template<typename T> - using string_map_t = std::map<std::string, T, std::less<void>>; + using string_map_t = ordered_map<std::string, T>; /* String set type supporting heterogeneous key lookup */ - using string_set_t = std::set<std::string, std::less<void>>; + using string_set_t = ordered_set<std::string>; namespace NodeTools { @@ -137,7 +140,7 @@ namespace OpenVic { node_callback_t expect_dictionary(key_value_callback_t callback); struct dictionary_entry_t { - const enum class expected_count_t : uint8_t { + enum class expected_count_t : uint8_t { _MUST_APPEAR = 0b01, _CAN_REPEAT = 0b10, @@ -146,7 +149,7 @@ namespace OpenVic { ZERO_OR_MORE = _CAN_REPEAT, ONE_OR_MORE = _MUST_APPEAR | _CAN_REPEAT } expected_count; - const node_callback_t callback; + node_callback_t callback; size_t count; dictionary_entry_t(expected_count_t new_expected_count, node_callback_t new_callback) @@ -344,8 +347,8 @@ namespace OpenVic { }; } - template<typename T> - Callback<T const&> auto set_callback_pointer(std::set<T const*>& set) { + template<typename T, typename...SetArgs> + Callback<T const&> auto set_callback_pointer(tsl::ordered_set<T const*, SetArgs...>& set) { return [&set](T const& val) -> bool { set.insert(&val); return true; |