I want to create std::map with "T,int" but manually. I've copied std::set of data into clear vector, because I want to have an access to elements of unique elements. Here is a following code.
template<typename T>
void foo<T>::function()
{
std::set<T> unique_set(A.begin(), A.end());
std::copy(A.begin(), A.end(), std::inserter(vector_uniq, vector_uniq.begin()));
for (const auto&elem : vector_uniq)
{
counter = std::count(A.begin(), A.end(), elem); // declared in header as unsigned int
}
}
Is it possible to push value of counter to another vector ? Then I would have two vectors of value and their occurences and those two vectors will be used in another function. That's why I would like to have separated containers. Thank's for all responses.
Aucun commentaire:
Enregistrer un commentaire