Skip to content

Instantly share code, notes, and snippets.

@Idorobots
Last active December 14, 2015 03:29
Show Gist options
  • Save Idorobots/5021523 to your computer and use it in GitHub Desktop.
Save Idorobots/5021523 to your computer and use it in GitHub Desktop.
Simple Hillis-Steele inclusive scan algorithm implementation.
V hillis_steele(alias op, V)(V array) {
for(size_t i = 1; i < array.length; i *= 2) {
for(size_t j = array.length; j > 0; --j) {
if(j > i) {
array[j-1] = op(array[j-1-i], array[j-1]);
}
}
}
return array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment