Let's say, that I have a following vector:
std::vector<double> v = {1,2,3,4,5,6,7,8};
Now I need to select several subsets of 3 elements (or less), i.e. something like this:
v.select(3) // {2,5,6}
v.select(3) // {1,7,8}
v.select(3) // Remaining elements {3,4}
The point is, that I need to do this on a vector of objects (not double
), which is very large, i.e. using shuffle() and selecting first n
elements seems to be a huge overhead. Also, the elements from previous selections must not be included in new ones.
Is there any way how to do this as time-efficiently as possible?
Aucun commentaire:
Enregistrer un commentaire