As far as I can tell, inplace_merge does the same thing as sort, except that it only works in certain circumstances (when the container is already in two sorted parts).
In other words, is there a difference between the two:
int first[] = {1,3,5,7}; int second[] = {2,4,6,8}; vector<int> v(8); vector<int>::iterator it; copy(first,first+4, v.begin()); copy(second,second+4, v.begin()+4); inplace_merge(v.begin(), v.begin()+4, v.end())
.
int first[] = {1,3,5,7}; int second[] = {2,4,6,8}; vector<int> v(8); vector<int>::iterator it; copy(first,first+4, v.begin()); copy(second,second+4, v.begin()+4); sort(v.begin(), v.end())
Will there be a difference only in efficiency?
c ++ stl
Alexander Bird
source share