Update reference code
This commit is contained in:
parent
e4d45e470c
commit
75efe84317
11
bucksort.cpp
11
bucksort.cpp
@ -13,6 +13,8 @@ bool LT(int a, int b)
|
|||||||
return a < b;
|
return a < b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: parallellize rotate-left instruction (BSL)
|
||||||
|
// This can be done by partially unrolling the loop ;)
|
||||||
// Bucket/Insertion sort (except final merge). C-style pseudocode
|
// Bucket/Insertion sort (except final merge). C-style pseudocode
|
||||||
void bi_sort(short *data){
|
void bi_sort(short *data){
|
||||||
short *buckets;
|
short *buckets;
|
||||||
@ -43,15 +45,16 @@ void bi_sort(short *data){
|
|||||||
|
|
||||||
while(lc_ != 0){
|
while(lc_ != 0){
|
||||||
++pc_;
|
++pc_;
|
||||||
hr = data[pc_];
|
ar = data[pc_];
|
||||||
if(hr > gr){
|
if((ar -= gr) < 0){
|
||||||
|
ar += gr;
|
||||||
data[pc_] = gr;
|
data[pc_] = gr;
|
||||||
// Insert here
|
// Insert here
|
||||||
while(lc_ != 0){
|
while(lc_ != 0){
|
||||||
++pc_;
|
++pc_;
|
||||||
gr = data[pc_];
|
gr = data[pc_];
|
||||||
data[pc_] = hr;
|
data[pc_] = ar;
|
||||||
hr = gr;
|
ar = gr;
|
||||||
--lc_;
|
--lc_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user