NAME
kjb_sort - Sorts an array of arbitrary elements.
SYNOPSIS
#include "l/l_sort.h"
Example compile flags (system dependent):
-DLINUX_386 -DLINUX_386_P4
-I/home/kobus/include
-L/home/kobus/load/linux_386_p4 -L/usr/local/lib -L/usr/lib
-lKJB -llapack -lblas -lg2c -lXext -lX11
int kjb_sort
(
void *array,
int num_elements,
size_t element_size,
int (*cmp_fn)(const void *,const void *),
int interrupt_action
);
DESCRIPTION
kjb_sort is similar to the widely available system routine "qsort" (is this
in ANSI-C now? I forget), but will provide the same facility as qsort in
environments where a acceptable qsort is not available (this is starting to
be rare - perhaps this routine has outgrown its usefullness). A few extra
features are provided at the expense of speed. If the fastest possible sort
is required, qsort should be faster (since this is what writers of this sort
of routine tend to optimize.).
The main functional difference between kjb_sort and qsort is the handling of
user interupt which is specified by the last parameter. If the last
parameter is USE_CURRENT_ATN_HANDLING, then there is not difference.
However a built in handler can be specified with USE_SORT_ATN_HANDLING. With
this handler, if the user interupts the sorting, they will be be prompted to
whether or not they want to continue. If they respond affirmitively, then
the sorting proceeds. Otherwise, the sorting is interrupted, and INTERRUPTED
is returned. A third choice for the last parameter is DISABLE_ATN_HANDLING.
With this choice, normal attention interupts are ignored during the sort.
For sorting on integer keys, the routine int_sort should be faster, since
call backs are not required for comparison.
RETURNS
On success kjb_sort returns the number calls to the comparison required.
If there was an error, then ERROR is returned. On failure ERROR is
returned and an error message is set. In addition, if
USE_SORT_ATN_HANDLING is used, and the sort was interrupted, INTERRUPTED
is returned.
DISCLAIMER
This software is not adequatedly tested. It is recomended that
results are checked independantly where appropriate.
AUTHOR
Kobus Barnard
DOCUMENTOR
Kobus Barnard
SEE ALSO
int_sort
,
long_sort
,
binary_search
,
int_binary_search
,
long_binary_search
,
binary_search_int_array
,
binary_search_long_array
,
linear_search
,
int_linear_search
,
long_linear_search
,
linear_search_int_array
,
linear_search_long_array