NAME

int_sort - Sorts an array of arbitrary elements by integer key.

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 int_sort
(
	void *array,
	int num_elements,
	size_t element_size,
	size_t key_pos,
	int interrupt_action
);

DESCRIPTION

This routine is much like kjb_sort except the call backs are avoided on the assumption that the key is an integer at offset key_pos (see offsetof()). This routine is barely legal ANSI-C and might fail on some bizzare system (but not anything common). The operation in question is whether:

       (int*)((void*)((char*)array + element_size*n + key_pos))

evaluates to a valid pointer to the n'th integer key, where key_pos is offsetof() the integer key, and element_size is sizeof(<element-type>). (I don't know of any systems where this is not the case). This routine is only meant to provide a faster sort in this specialized case, so if you don't want to take a chance with the above then kjb_sort or qsort can be used. The interupt handling is the same as kjb_sort (see kjb_sort(3)).

RETURNS

On success int_sort returns the number of key comparisons 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

kjb_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