23 auto &front = data.front();
24 const int key_position = std::distance(front.cbegin(), front.find(key));
26 tmp.reserve(data.size());
30 for (
const auto &d : data)
32 tmp[*std::next(d.cbegin(), key_position)] = index++;
36 if (tmp.size() != data.size())
std::string Str
Str is an alias for string.
nlohmann::json Json
Json is an alias for nlohmann::json.
void runtime_error(const Str &msg)
Raise (for Python) and throw (for C++) a runtime error.
This file has a definition of utils::map_to_index.
This file has a definition of utils::runtime_error.
Namespace for utility functions.
std::unordered_map< T, U > Map
Map is an alias for unordered map (same as dict in Python).
Map< Json, int > map_to_index(const Json &data, const Str &key)
Create a Map object from values of selected property in an array Json object to corresponding index i...