dimanche 2 avril 2017

limit std::vector for given min and max values

I've a std::vector of double values and I'm searching for a way to limit the sorted result to certain min and max values. Let me provide an example -

std::vector<double> v;
v.push_back(2.5);
v.push_back(3.5);
v.push_back(4.5);
v.push_back(5.5);
v.push_back(6.5);

In above example, if I execute limit(v, 4.0, 7.0); it should provide me indexes eg [2] to [4] or end or whatever. I tried searching for <algorithm> header but couldn't find one :/ I can use additional library too if the need arises.

Aucun commentaire:

Enregistrer un commentaire