Here is the code that I wanted to optimize,
Var = std::map<std::string, std::set<std::string>>;
Var has a key and set of values, now I wanted to find how many times a value is used in the overall map and I wrote the following,
std::map<std::string, int> Rate;
for (const auto& key : Var)
{
for (const auto& par : key.second)
{
Rate[key.first] = key.second.size();
}
}
Now, I am wondering if I can reduce the above loops into a single loop or any other optimization possible.
Aucun commentaire:
Enregistrer un commentaire