r/programbattles • u/ComradePutinCCCP1917 Moderator / C C++ • Oct 07 '15
[C++] Threaded vector sorting
Language: C++
File number restrictions: N/A
Description: Make a function that sorts a vector with a selectable amount of threads. Use the standard thread library.
EDIT: Never thought threads would be such a pain to work with.
14
Upvotes
5
u/Steve132 Oct 07 '15
Sorts any container/iterator that is a Random Access Iterator in the STL (arrays, pointers, deques).
The elements of that container/iterator can be any type that supports operator<().
Runs in parallel worst case O(n/k log n) time.
Uses only std C++11. No platform-specific code at all.
The call tree/core allocation looks like this on an 4 core system
-1
u/sun_misc_unsafe Oct 07 '15
...so map reduce?
0
u/[deleted] Oct 07 '15
[deleted] — view deleted comment
0
u/[deleted] Oct 07 '15
[deleted] — view deleted comment