Reputation: 169
Here is an example of what I am trying to do:
int size = 10;
int *data = new int[size];
int *array_1 = &data[0];
int *array_2 = &data[size/2];
//fill array_1 and array_2 with data
sort(array_1, array_1+size/2);
sort(array_2, array_2+size/2);
//now, is it possible to merge the 2 sorted arrays?
For example if array_1 = {1, 4, 7}
and array_2 = {3, 5, 6}
I am trying to make data = {1, 3, 4, 5, 6, 7}
Upvotes: 0
Views: 170
Reputation:
You want std::inplace_merge. See http://www.cplusplus.com/reference/algorithm/inplace_merge/
Upvotes: 1