diff --git a/magyarsort.h b/magyarsort.h index 27e7146..7b6bd2c 100644 --- a/magyarsort.h +++ b/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 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); } };