Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Examples  

sort.h File Reference

Go to the source code of this file.

Functions

int issort (void *donnee, int nb_elts, int taille_elt, int(*compare)(const void *cle1, const void *cle2))
 Sort data using the insertion method.

int extended_issort (void *donnee, int nb_elts, int taille_elt, int(*compare)(const void *cle1, const void *cle2), int(*copy_data)(void *src, void *dest), int(*init_elem)(void *elm))
 Extended version of the function issort(). This can be used to handle complex data.

int qksort (void *donnee, int nb_elts, int taille_elt, int i, int k, int(*compare)(const void *cle1, const void *cle2))
 Sort data using the QuickSort algorithm.

int extended_qksort (void *donnee, int nb_elts, int taille_elt, int i, int k, int(*compare)(const void *cle1, const void *cle2), int(*copy_data)(void *src, void *dest), int(*init_elem)(void *elm))
 Sort data using the QuickSort algorithm.


Detailed Description

Header file for qksort.c

Definition in file sort.h.


Function Documentation

int extended_issort void *    donnee,
int    nb_elts,
int    taille_elt,
int(*    compare)(const void *cle1, const void *cle2),
int(*    copy_data)(void *src, void *dest),
int(*    init_elem)(void *elm)
 

Extended version of the function issort(). This can be used to handle complex data.

Parameters:
donnee Pointer to the beginning of the array to sort.
nb_elts Number of elements in the array.
compare User defined function used to compare two elements of the array. If you want to sort according to increasing values, then the function compare() should return:
  • 1 if cle1 > cle2
  • 0 if cle1 == cle2
  • -1 if cle1 < cle2
If you want to sort according to decreasing values, then the function compare() should return:
  • 1 if cle1 < cle2
  • 0 if cle1 == cle2
  • -1 if cle1 > cle2
copy_data User defined function used to copy data. The function must take care of memory management. This function must return:
  • 0 upon successful completion.
  • 1 if an error occured.
init_elem User defined function used to initialize an element. You can specify a NULL pointer if you do not need to initialize elements. This function must return:
  • 0 upon successful completion.
  • 1 if an error occured.
This function is called whenever a new element is allocated.
Returns:
Upon successful completion the function returns 0, otherwise it returns -1
Warning:
This function is not suitable if you need to sort an inportant number of element.

Definition at line 121 of file issort.c.

int extended_qksort void *    donnee,
int    nb_elts,
int    taille_elt,
int    i,
int    k,
int(*    compare)(const void *cle1, const void *cle2),
int(*    copy_data)(void *src, void *dest),
int(*    init_elem)(void *elm)
 

Sort data using the QuickSort algorithm.

Parameters:
donnee Pointer to the beginning of the array to sort.
nb_elts Number of elements to sort.
taille_elt Size in bytes of an element.
i i MUST BE set to 0.
k k MUST BE set to nb_elts - 1.
compare User defined function used to compare two elements of the array. If you want to sort according to increasing values, then the function compare() should return:
  • 1 if cle1 > cle2
  • 0 if cle1 == cle2
  • -1 if cle1 < cle2
If you want to sort according to decreasing values, then the function compare() should return:
  • 1 if cle1 < cle2
  • 0 if cle1 == cle2
  • -1 if cle1 > cle2
copy_data User defined function used to copy data. The function must take care of memory management. This function must return:
  • 0 upon successful completion.
  • 1 if an error occured.
init_elem User defined function used to initializen an element. This function must return:
  • 0 upon successful completion.
  • 1 if an error occured.
This function is called whenever a new element is allocated. Please note that you can specify a NULL pointer if no initialization is needed.
Returns:
Upon successful completion the function returns 0, otherwise it returns -1

Definition at line 293 of file qksort.c.

int issort void *    donnee,
int    nb_elts,
int    taille_elt,
int(*    compare)(const void *cle1, const void *cle2)
 

Sort data using the insertion method.

Parameters:
donnee Pointer to the beginning of the array to sort.
nb_elts Number of elements in the array.
taille_elt Size in bytes of one element.
compare User defined function used to compare two elements of the array. If you want to sort according to increasing values, then the function compare() should return:
  • 1 if cle1 > cle2
  • 0 if cle1 == cle2
  • -1 if cle1 < cle2
If you want to sort according to decreasing values, then the function compare() should return:
  • 1 if cle1 < cle2
  • 0 if cle1 == cle2
  • -1 if cle1 > cle2
Returns:
Upon successful completion the function returns 0, otherwise it returns -1
Warning:
This function is not suitable if you need to sort an inportant number of element.

Definition at line 34 of file issort.c.

Referenced by array_rem_all().

int qksort void *    donnee,
int    nb_elts,
int    taille_elt,
int    i,
int    k,
int(*    compare)(const void *cle1, const void *cle2)
 

Sort data using the QuickSort algorithm.

Parameters:
donnee Pointer to the beginning of the array to sort.
nb_elts Number of elements to sort.
taille_elt Size in bytes of an element.
i i MUST BE set to 0.
k k MUST BE set to nb_elts - 1.
compare User defined function used to compare two elements of the array. If you want to sort according to increasing values, then the function compare() should return:
  • 1 if cle1 > cle2
  • 0 if cle1 == cle2
  • -1 if cle1 < cle2
If you want to sort according to decreasing values, then the function compare() should return:
  • 1 if cle1 < cle2
  • 0 if cle1 == cle2
  • -1 if cle1 > cle2
Returns:
Upon successful completion the function returns 0, otherwise it returns -1

Definition at line 127 of file qksort.c.


Generated on Thu Apr 3 16:23:47 2003 for Common_C_libraries by doxygen1.3-rc1