Skip to content

Instantly share code, notes, and snippets.

@Zekt
Last active January 9, 2016 14:44
Show Gist options
  • Save Zekt/b300df04e90b7e1fc5c7 to your computer and use it in GitHub Desktop.
Save Zekt/b300df04e90b7e1fc5c7 to your computer and use it in GitHub Desktop.
Split a vector into fixed-size blocks and handle remaining objects. #Iterate #Split #Block
int* input = new int[num];
vector<thread> threads;
int i;
for(i = 0; i+segment_size < num; i += segment_size)
threads.push_back(thread(sort_segment, input+i, segment_size));
if(num-i > 0)
threads.push_back(thread(sort_segment, input+i, num-i));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment