S
Scott Meyers
At http://wordaligned.org/articles/top-ten-percent , Thomas Guest shows
how he found that running nth_element followed by sort produced results
*much* faster than simply running partial_sort. I ran the test myself,
and I got the same kinds of results he did. I've mentioned this to
others, and some have been motivated to run the test themselves.
They've been as astonished as me at the results.
What are others' experiences with and comments about using nth_element
followed by sort instead of partial_sort to sort the top part of some
range of values? For purposes of discussion, assume that random access
iterators are available.
Thanks,
Scott
how he found that running nth_element followed by sort produced results
*much* faster than simply running partial_sort. I ran the test myself,
and I got the same kinds of results he did. I've mentioned this to
others, and some have been motivated to run the test themselves.
They've been as astonished as me at the results.
I recently stumbled across partial_sort in stl; fwiw,
stdartial_sort( A, A + sqrt(N), A + N ) is ~ 10 times faster than
std:sort
on my old mac ppc, even for N 100.
Also fwiw, nth_element alone is ~ twice as slow as partial_sort --
odd.
What are others' experiences with and comments about using nth_element
followed by sort instead of partial_sort to sort the top part of some
range of values? For purposes of discussion, assume that random access
iterators are available.
Thanks,
Scott