Created
June 9, 2018 18:31
-
-
Save ahupowerdns/0869aa466a970b6325d6e38d56e71f39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <vector> | |
#include <parallel/algorithm> | |
using namespace std; | |
extern "C" int cmp(const void* a, const void* b) | |
{ | |
return *(int*)a < *(int*)b; | |
} | |
int main(int argc, char**argv) | |
{ | |
auto lim = atoi(argv[1]); | |
vector<int> blah; | |
blah.reserve(lim); | |
for(int n=0 ; n < lim; ++n) | |
blah.push_back(random()); | |
if(*argv[2]=='q') | |
qsort(&blah[0], blah.size(), sizeof(int), cmp); | |
else if(*argv[2]=='p') | |
__gnu_parallel::sort(blah.begin(), blah.end()); | |
else if(*argv[2]=='s') | |
sort(blah.begin(), blah.end()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment