lundi 23 mars 2020

std::vector transform to std::map [closed]

I have an std::vector<C> that I want to transform to an std::map<int, std::vector<int>>, where the key will be the category_id and the value will be a vector of all winners for this category.

struct C {
    int category_id;
    int winner;
}

How can I do the above transformation? Shall I use two for loops one for the keys and one for the values?

Aucun commentaire:

Enregistrer un commentaire