Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static const unsigned long counting_table[16 * 16];
- static const unsigned long result_table[16 * 16 * 8];
- static const unsigned char shifting_table[16 *16];
- void counting_nibble_sort_lookup(unsigned long* buf)
- {
- for (int num = 0; num < 1024; num++) {
- unsigned long value = buf[num];
- unsigned long count = 0;
- for (int i = 0; i < 16; i += 2)
- count += counting_table[(value >> (i * 4)) & 0xFF];
- if ((count & (count - 1)) == 0)
- continue;
- unsigned long result = 0;
- for (int i = 0; i < 16; i += 2) {
- int double_nibble_count = ((count >> (56 - 4 * i)) & 0xFF);
- result <<= shifting_table[double_nibble_count];
- result |= result_table[double_nibble_count + i * 16 * 8];
- }
- buf[num] = result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement