Is there a good way to map vectors? Here's an example of what I mean:

vec0 = [0,0,0,0,0,0,0,0,0,0,0]
vec1 = [1,4,2,7,3,2]
vec2 = [0,0,0,0,0,0,0,0,0]
vec2 = [7,2,7,9,9,6,1,0,4]
vec4 = [0,0,0,0,0,0]

mainvec =

Lets say mainvec doesn't exist (I'm just showing it to you so you can see the general data structure in mind.

Now say I want mainvec(12) which would be 4. Is there a good way to map the call of these vectors without just stitching them together into a mainvec? I realize I could make a bunch of if statements that test the index of mainvec and I can then offset each call depending on where the call is within one of the vectors, so for instance:

mainvec(12) = vec1(1)

which I could do by:

if (index >=13)

I wonder if there's a concise way of doing this without if statements. Any Ideas?

Sounds like you want to concatenate vectors? You can do

vector1.insert( vector1.end(), vector2.begin(), vector2.end() );

to append vector2 to the end of vector1.

An equivalent statement is

std::copy(source.begin(), source.end(), std::back_inserter(destination));

Don't forget to vote for answer cataloging so this can be added to a solution database somewhere!: