[fix] making ksort methods static
This commit is contained in:
@@ -54,7 +54,7 @@ typedef struct {
|
||||
#define KSORT_SWAP(type_t, a, b) { register type_t t=(a); (a)=(b); (b)=t; }
|
||||
|
||||
#define KSORT_INIT(name, type_t, __sort_lt) \
|
||||
void ks_mergesort_##name(size_t n, type_t array[], type_t temp[]) \
|
||||
static void ks_mergesort_##name(size_t n, type_t array[], type_t temp[]) \
|
||||
{ \
|
||||
type_t *a2[2], *a, *b; \
|
||||
int curr, shift; \
|
||||
@@ -102,7 +102,7 @@ typedef struct {
|
||||
} \
|
||||
if (temp == 0) free(a2[1]); \
|
||||
} \
|
||||
void ks_heapadjust_##name(size_t i, size_t n, type_t l[]) \
|
||||
static void ks_heapadjust_##name(size_t i, size_t n, type_t l[]) \
|
||||
{ \
|
||||
size_t k = i; \
|
||||
type_t tmp = l[i]; \
|
||||
@@ -113,13 +113,13 @@ typedef struct {
|
||||
} \
|
||||
l[i] = tmp; \
|
||||
} \
|
||||
void ks_heapmake_##name(size_t lsize, type_t l[]) \
|
||||
static void ks_heapmake_##name(size_t lsize, type_t l[]) \
|
||||
{ \
|
||||
size_t i; \
|
||||
for (i = (lsize >> 1) - 1; i != (size_t)(-1); --i) \
|
||||
ks_heapadjust_##name(i, lsize, l); \
|
||||
} \
|
||||
void ks_heapsort_##name(size_t lsize, type_t l[]) \
|
||||
static void ks_heapsort_##name(size_t lsize, type_t l[]) \
|
||||
{ \
|
||||
size_t i; \
|
||||
for (i = lsize - 1; i > 0; --i) { \
|
||||
@@ -135,7 +135,7 @@ typedef struct {
|
||||
swap_tmp = *j; *j = *(j-1); *(j-1) = swap_tmp; \
|
||||
} \
|
||||
} \
|
||||
void ks_combsort_##name(size_t n, type_t a[]) \
|
||||
static void ks_combsort_##name(size_t n, type_t a[]) \
|
||||
{ \
|
||||
const double shrink_factor = 1.2473309501039786540366528676643; \
|
||||
int do_swap; \
|
||||
@@ -157,7 +157,7 @@ typedef struct {
|
||||
} while (do_swap || gap > 2); \
|
||||
if (gap != 1) __ks_insertsort_##name(a, a + n); \
|
||||
} \
|
||||
void ks_introsort_##name(size_t n, type_t a[]) \
|
||||
static void ks_introsort_##name(size_t n, type_t a[]) \
|
||||
{ \
|
||||
int d; \
|
||||
ks_isort_stack_t *top, *stack; \
|
||||
@@ -210,7 +210,7 @@ typedef struct {
|
||||
} \
|
||||
/* This function is adapted from: http://ndevilla.free.fr/median/ */ \
|
||||
/* 0 <= kk < n */ \
|
||||
type_t ks_ksmall_##name(size_t n, type_t arr[], size_t kk) \
|
||||
static type_t ks_ksmall_##name(size_t n, type_t arr[], size_t kk) \
|
||||
{ \
|
||||
type_t *low, *high, *k, *ll, *hh, *mid; \
|
||||
low = arr; high = arr + n - 1; k = arr + kk; \
|
||||
@@ -237,7 +237,7 @@ typedef struct {
|
||||
if (hh >= k) high = hh - 1; \
|
||||
} \
|
||||
} \
|
||||
void ks_shuffle_##name(size_t n, type_t a[]) \
|
||||
static void ks_shuffle_##name(size_t n, type_t a[]) \
|
||||
{ \
|
||||
int i, j; \
|
||||
for (i = n; i > 1; --i) { \
|
||||
@@ -246,7 +246,7 @@ typedef struct {
|
||||
tmp = a[j]; a[j] = a[i-1]; a[i-1] = tmp; \
|
||||
} \
|
||||
} \
|
||||
void ks_sample_##name(size_t n, size_t r, type_t a[]) /* FIXME: NOT TESTED!!! */ \
|
||||
static void ks_sample_##name(size_t n, size_t r, type_t a[]) /* FIXME: NOT TESTED!!! */ \
|
||||
{ /* reference: http://code.activestate.com/recipes/272884/ */ \
|
||||
int i, k, pop = n; \
|
||||
for (i = (int)r, k = 0; i >= 0; --i) { \
|
||||
|
||||
Reference in New Issue
Block a user