Re: how to parallel sort?
On 3=D4 9=C8=D5, =C9=CF=CE=E79=CA=B139=B7=D6, nandor.sie...@gmail.com wrot=
e:
I have a vector of integers something like v=(2,1,5,4). I'd like to
create a vector containing the indices in order of the values of this
vector. So the output would be (1,0,3,2). Note that
v[0]<v[1]<v[3]<v[2]. What's the easiest/most efficient way to do
this?
Is there something like a parallel sort that takes two vectors as its
input, sorts the first one and makes the same changes two the second
vector. So if v=(2,1,5,4) and w=(0,1,2,3) then parallel_sort(v,w)
would change this into v=(1,2,4,5) and w=(1,0,3,2).
Of course I can do this on my own with loops but I think that would
not be very efficient. I cannot match the built in STL sort algorithm.
What I'd like to know if there is an effective way of doing this with
the STL algorithms.
Have a look at boost::zip_iterator
@(http://www.boost.org/libs/iterator/doc/zip_iterator.html)
IIRC, VC8's vector::iterator implementation doesn't support
zip_iterator
to modify the value referred by zip_iterator (Proxy).