Bsoft  2.1.0
Bernard's software package
qsort_functions.cpp
Go to the documentation of this file.
1 
9 #include "qsort_functions.h"
10 
17 int QsortSmallToLargeFloat(const void *x, const void *y)
18 {
19  float* r1 = (float*) x;
20  float* r2 = (float*) y;
21  if( *r1 < *r2 ) return -1;
22  else return 1;
23 }
24 
31 int QsortLargeToSmallFloat(const void *x, const void *y)
32 {
33  float* r1 = (float*) x;
34  float* r2 = (float*) y;
35  if( *r1 > *r2 ) return -1;
36  else return 1;
37 }
38 
45 int QsortSmallToLargeDouble(const void *x, const void *y)
46 {
47  double* r1 = (double*) x;
48  double* r2 = (double*) y;
49  if( *r1 < *r2 ) return -1;
50  else return 1;
51 }
52 
59 int QsortLargeToSmallDouble(const void *x, const void *y)
60 {
61  double* r1 = (double*) x;
62  double* r2 = (double*) y;
63  if( *r1 > *r2 ) return -1;
64  else return 1;
65 }
66 
73 int QsortSmallToLargeIntFloat(const void *x,const void *y)
74 {
75  int_float* r1 = (int_float *) x;
76  int_float* r2 = (int_float *) y;
77 
78  if ( r1->f < r2->f ) return -1;
79  else if ( r1->f > r2->f ) return 1;
80  else return 0;
81 }
82 
89 int QsortLargeToSmallIntFloat(const void *x,const void *y)
90 {
91  int_float* r1 = (int_float *) x;
92  int_float* r2 = (int_float *) y;
93 
94  if ( r1->f > r2->f ) return -1;
95  else if ( r1->f < r2->f ) return 1;
96  else return 0;
97 }
98 
qsort_functions.h
Header file for utility functions for use in qsort calls.
QsortSmallToLargeDouble
int QsortSmallToLargeDouble(const void *x, const void *y)
Utility function for sorting double precision floating point values in qsort.
Definition: qsort_functions.cpp:45
int_float::f
float f
Definition: qsort_functions.h:12
QsortLargeToSmallDouble
int QsortLargeToSmallDouble(const void *x, const void *y)
Utility function for sorting double precision floating point values in qsort.
Definition: qsort_functions.cpp:59
int_float
Definition: qsort_functions.h:12
QsortSmallToLargeIntFloat
int QsortSmallToLargeIntFloat(const void *x, const void *y)
Utility function for sorting int float pairs in qsort.
Definition: qsort_functions.cpp:73
QsortSmallToLargeFloat
int QsortSmallToLargeFloat(const void *x, const void *y)
Utility function for sorting floating point values in qsort.
Definition: qsort_functions.cpp:17
QsortLargeToSmallIntFloat
int QsortLargeToSmallIntFloat(const void *x, const void *y)
Utility function for sorting int float pairs in qsort.
Definition: qsort_functions.cpp:89
QsortLargeToSmallFloat
int QsortLargeToSmallFloat(const void *x, const void *y)
Utility function for sorting floating point values in qsort.
Definition: qsort_functions.cpp:31