tried if it works with nibbles too: seems like easier to debug actually in this mode
This commit is contained in:
parent
151b8f398b
commit
1d0ba81e49
28
magyarsort.h
28
magyarsort.h
@ -23,9 +23,9 @@ namespace MagyarSort {
|
||||
// - DIGIT_RANGE and BITS_PER_DIGIT should correspond
|
||||
// - DIGITS should also correspond with the uint32_t
|
||||
// - and DIGIT_RANGE should be 2^n value (16 or 256)
|
||||
static constexpr int DIGITS = 4; // "helyiérték"
|
||||
static constexpr int BITS_PER_DIGIT = 8; // "bit / helyiérték"
|
||||
static constexpr int DIGIT_RANGE = 256; // "helyiérték állapottér"
|
||||
static constexpr int DIGITS = 8; // "helyiérték"
|
||||
static constexpr int BITS_PER_DIGIT = 4; // "bit / helyiérték"
|
||||
static constexpr int DIGIT_RANGE = 16; // "helyiérték állapottér"
|
||||
|
||||
template<int DIGIT_CHOICE>
|
||||
static inline uint32_t getDigit(uint32_t num) noexcept {
|
||||
@ -83,6 +83,16 @@ namespace MagyarSort {
|
||||
}
|
||||
}
|
||||
|
||||
void debugIt(size_t *radics) {
|
||||
for(size_t j = 0; j < DIGITS; ++j) {
|
||||
printf("d%d: ", j);
|
||||
for(size_t i = 0; i < DIGIT_RANGE; ++i) {
|
||||
printf("%d,", radics[i + DIGIT_RANGE*j]);
|
||||
}
|
||||
printf("\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
/** Sort the given array (in-place sorting) with the given size */
|
||||
inline void sort(uint32_t arr[], size_t size) noexcept {
|
||||
// Holds "digit" occurences, prefix sums, whatevers
|
||||
@ -93,18 +103,12 @@ namespace MagyarSort {
|
||||
// Calculate occurences of digits
|
||||
countOccurences(arr, size, radics);
|
||||
|
||||
debugIt(radics);
|
||||
|
||||
// Calculate prefix sums
|
||||
calcPrefixSums(radics);
|
||||
|
||||
/* // DEBUG:
|
||||
*/
|
||||
for(size_t j = 0; j < DIGITS; ++j) {
|
||||
printf("d%d: ", j);
|
||||
for(size_t i = 0; i < DIGIT_RANGE; ++i) {
|
||||
printf("%d,", radics[i + DIGIT_RANGE*j]);
|
||||
}
|
||||
printf("\n\n");
|
||||
}
|
||||
debugIt(radics);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user