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

issort.c 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.


Detailed Description

This file implements sorting by insersion

Definition in file issort.c.


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.
Examples:
test_ext_sort.c.

Definition at line 121 of file issort.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.
Examples:
test_sort.c.

Definition at line 34 of file issort.c.

Referenced by array_rem_all().


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