MCPcopy Create free account
hub / github.com/DFHack/dfhack / computeInitVariationTable

Function computeInitVariationTable

library/Core.cpp:1727–1749  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1725
1726 template <VariationTableTypes... Ts>
1727 static EntryVector computeInitVariationTable(Ts&&... ts) {
1728 using Arg = std::variant<Key, std::string_view>;
1729 std::vector<Arg> args{ Arg{std::forward<Ts>(ts)}... };
1730
1731 Key current_key = SC_UNKNOWN;
1732 EntryVector result;
1733 Val val;
1734 for (auto& arg : args) {
1735 if (std::holds_alternative<Key>(arg)) {
1736 if (current_key != SC_UNKNOWN && !val.empty()) {
1737 result.emplace_back(current_key, val);
1738 val.clear();
1739 }
1740 current_key = std::get<Key>(arg);
1741 } else if (std::holds_alternative<std::string_view>(arg)) {
1742 auto str = std::get<std::string_view>(arg);
1743 if (!str.empty())
1744 val.emplace_back(str);
1745 }
1746 }
1747
1748 return result;
1749 }
1750
1751 static InitVariationTable getTable(const EntryVector& vec) {
1752 return InitVariationTable(vec.begin(),vec.end());

Callers 1

Calls 2

emptyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected