bucketsort: add comments
This commit is contained in:
parent
7bafc2bbab
commit
ebb2a0279c
@ -2,6 +2,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "bucketsort.h"
|
#include "bucketsort.h"
|
||||||
|
|
||||||
|
// Printable characters in Ascii (from 34 to 127);
|
||||||
|
// actually 127 is also not printable
|
||||||
#define N_BUCKETS 94
|
#define N_BUCKETS 94
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -42,6 +44,7 @@ long int* bucket_sort(char *a, int length, long int size) {
|
|||||||
|
|
||||||
// copy the keys to "buckets"
|
// copy the keys to "buckets"
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
|
// 0x21 = 33d, number of unprintable characters in Ascii
|
||||||
b = &buckets[*(a + i * length) - 0x21];
|
b = &buckets[*(a + i * length) - 0x21];
|
||||||
b->data[b->total++] = i;
|
b->data[b->total++] = i;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user