X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=ucw%2Fsorter%2Farray.h;h=e6e0199d0f9bdff4984b2d996adee5beb410dc9e;hb=25541ea3bb96e9f143f0e23f8ac5b432f2f6f47a;hp=740b9b6e6814c13b5c2e2c0709db6a9fe241b982;hpb=031256ad2e123eec58521f8e3eb9496c197641d2;p=libucw.git diff --git a/ucw/sorter/array.h b/ucw/sorter/array.h index 740b9b6e..e6e0199d 100644 --- a/ucw/sorter/array.h +++ b/ucw/sorter/array.h @@ -9,7 +9,7 @@ /* * This is a generator of routines for sorting huge arrays, similar to the one - * in ucw/arraysort.h. It cannot handle discontiguous arrays, but it is able + * in ucw/sorter/array-simple.h. It cannot handle discontiguous arrays, but it is able * to employ radix-sorting if a monotone hash function is available and also * use several threads in parallel on SMP systems (this assumes that all * callbacks you provide are thread-safe). @@ -284,11 +284,25 @@ static void Q(radix_split)(void *src_ptr, void *dest_ptr, uns num_elts, uns *ptr #endif -static Q(key) *Q(sort)(Q(key) *array, uns num_elts #ifdef ASORT_HASH - , Q(key) *buffer, uns hash_bits +#define ASORT_HASH_ARGS , Q(key) *buffer, uns hash_bits +#else +#define ASORT_HASH_ARGS #endif - ) + +/** + * The generated function. The @array is the data to be sorted, @num_elts tells + * how many elements the array has. If you did not provide `ASORT_HASH`, then + * the `ASORT_HASH_ARGS` is empty (there are only the two parameters in that + * case). When you provide it, the function gains two more parameters in the + * `ASORT_HASH_ARGS` macro. They are `ASORT_KEY_TYPE *@buffer`, which must be a + * memory buffer of the same size as the input array, and `uns @hash_bits`, + * specifying how many significant bits the hash function returns. + * + * The function returns pointer to the sorted data, either the @array or the + * @buffer argument. + **/ +static ASORT_KEY_TYPE *ASORT_PREFIX(sort)(ASORT_KEY_TYPE *array, uns num_elts ASORT_HASH_ARGS) { struct asort_context ctx = { .array = array, @@ -318,4 +332,5 @@ static Q(key) *Q(sort)(Q(key) *array, uns num_elts #undef ASORT_RADIX_MASK #undef ASORT_SWAP #undef ASORT_THRESHOLD +#undef ASORT_HASH_ARGS #undef Q