Thu, 03 May 2018 10:09:49 +0200
adds distance functions for integers as utils
src/ucx/utils.h | file | annotate | diff | comparison | revisions | |
src/utils.c | file | annotate | diff | comparison | revisions |
1.1 --- a/src/ucx/utils.h Thu May 03 09:49:38 2018 +0200 1.2 +++ b/src/ucx/utils.h Thu May 03 10:09:49 2018 +0200 1.3 @@ -175,6 +175,25 @@ 1.4 */ 1.5 int ucx_longintcmp(const void *i1, const void *i2, void *data); 1.6 1.7 + 1.8 +/** 1.9 + * Distance function for integers of type int. 1.10 + * @param i1 pointer to integer one 1.11 + * @param i2 pointer to integer two 1.12 + * @param data omitted 1.13 + * @return i1 minus i2 1.14 + */ 1.15 +intmax_t ucx_intdist(const void *i1, const void *i2, void *data); 1.16 + 1.17 +/** 1.18 + * Distance function for integers of type long int. 1.19 + * @param i1 pointer to long integer one 1.20 + * @param i2 pointer to long integer two 1.21 + * @param data omitted 1.22 + * @return i1 minus i2 1.23 + */ 1.24 +intmax_t ucx_longintdist(const void *i1, const void *i2, void *data); 1.25 + 1.26 /** 1.27 * Compares two real numbers of type float. 1.28 * @param f1 pointer to float one
2.1 --- a/src/utils.c Thu May 03 09:49:38 2018 +0200 2.2 +++ b/src/utils.c Thu May 03 10:09:49 2018 +0200 2.3 @@ -116,6 +116,18 @@ 2.4 } 2.5 } 2.6 2.7 +intmax_t ucx_intdist(const void *i1, const void *i2, void *data) { 2.8 + intmax_t a = *((const int*) i1); 2.9 + intmax_t b = *((const int*) i2); 2.10 + return a - b; 2.11 +} 2.12 + 2.13 +intmax_t ucx_longintdist(const void *i1, const void *i2, void *data) { 2.14 + intmax_t a = *((const long int*) i1); 2.15 + intmax_t b = *((const long int*) i2); 2.16 + return a - b; 2.17 +} 2.18 + 2.19 int ucx_floatcmp(const void *f1, const void *f2, void *epsilon) { 2.20 float a = *((const float*) f1); 2.21 float b = *((const float*) f2);