temporarily do naive array separate code for debugging
This commit is contained in:
parent
fbea1e607c
commit
6073c03f81
@ -20,6 +20,9 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
// FIXME: vector is for debugging
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A binary search based function
|
* A binary search based function
|
||||||
* to find the position
|
* to find the position
|
||||||
@ -78,6 +81,7 @@ struct lr {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline struct lr internal_array_separate(uint32_t *t, int n, uint32_t low, uint32_t mid, uint32_t high) {
|
inline struct lr internal_array_separate(uint32_t *t, int n, uint32_t low, uint32_t mid, uint32_t high) {
|
||||||
|
/*
|
||||||
// Init left-right "write head" indices
|
// Init left-right "write head" indices
|
||||||
int left = 0;
|
int left = 0;
|
||||||
int right = n - 1;
|
int right = n - 1;
|
||||||
@ -105,6 +109,31 @@ inline struct lr internal_array_separate(uint32_t *t, int n, uint32_t low, uint3
|
|||||||
eler.left = left;
|
eler.left = left;
|
||||||
eler.right = right;
|
eler.right = right;
|
||||||
|
|
||||||
|
return eler;
|
||||||
|
*/
|
||||||
|
|
||||||
|
// FIXME: bad quality debug code to remove
|
||||||
|
std::vector<uint32_t> v(n);
|
||||||
|
int left = 0;
|
||||||
|
int right = n - 1;
|
||||||
|
auto current = t[0];
|
||||||
|
for(int i = 0; i < n; ++i) {
|
||||||
|
if(current < mid) {
|
||||||
|
v[left++] = current;
|
||||||
|
current = t[i + 1];
|
||||||
|
} else {
|
||||||
|
v[right--] = current;
|
||||||
|
current = t[i + 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int i = 0; i < n; ++i) {
|
||||||
|
t[i] = v[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
struct lr eler;
|
||||||
|
eler.left = left;
|
||||||
|
eler.right = right;
|
||||||
|
|
||||||
return eler;
|
return eler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user