next up previous contents
Next: Function: index_cmp() Up: GRASP Routines: General purpose Previous: Structure: struct removed_lines   Contents

Function: fvalue_cmp()

0 int fvalue_cmp(const void *f1, const void *f2)

This is a function which may be used to compare the fvalues of two different objects of type struct removed_lines. It is used for example as an argument to the standard-C library routine qsort for sorting lists of removed lines into decreasing order of fvalue.

This function is supplied with pointers to two stuctures. It returns -1 if the first structure has the larger fvalue, +1 if the first structure has the smaller fvalue, and 0 if the fvalues are equal.

The arguments are:

f1: Input. Pointer to the first structure of type struct removed_lines (cast to void * so that your compiler does not complain).
f2: Input. Pointer to the second structure of type struct removed_lines (cast to void * so that your compiler does not complain).

As an example, if line_list[0..n-1] is an array of struct removed_lines, then the function call:
qsort(line_list,n,sizeof(struct significant_values),fvalue_cmp)
will sort that array into decreasing fvalue order. (Note: you may have to cast the arguments to prevent your compiler from complaining.)

Author: Bruce Allen (ballen@dirac.phys.uwm.edu) and Adrian Ottewill (ottewill@relativity.ucd.ie).
Comments: None.


next up previous contents
Next: Function: index_cmp() Up: GRASP Routines: General purpose Previous: Structure: struct removed_lines   Contents
Bruce Allen 2000-11-19