Specify the begin and end indices instead of filling a vector with all the indices which are continuous anyway.