Say I have a vector / list whatever of ints populated with 2300 values
I want to be able to easily slice this into 4 vectors /lists (not necessarily of equal size).
e.g.
vec1 ( elements 0 - 500 )
vec2 ( elements 501 - 999)
vec3 ( elements 1001 - 1499)
etc.
A common way to do it would be to use the one container, and just define separate iterator ranges over it.
Now, the first range is simply defined by the iterators
it0andit1. The second byit1andit2, and so on.So, if you want to apply a function to every element in the third range, you’d simply do this:
Actually copying the elements into separate containers may be unnecessary, and would carry a performance cost.