Thu, 03 May 2018 09:49:38 +0200
adds ucx_longintcmp() compare function
src/ucx/utils.h | file | annotate | diff | comparison | revisions | |
src/utils.c | file | annotate | diff | comparison | revisions |
--- a/src/ucx/utils.h Thu May 03 09:26:06 2018 +0200 +++ b/src/ucx/utils.h Thu May 03 09:49:38 2018 +0200 @@ -166,6 +166,16 @@ int ucx_intcmp(const void *i1, const void *i2, void *data); /** + * Compares two integers of type long int. + * @param i1 pointer to long integer one + * @param i2 pointer to long integer two + * @param data omitted + * @return -1, if *i1 is less than *i2, 0 if both are equal, + * 1 if *i1 is greater than *i2 + */ +int ucx_longintcmp(const void *i1, const void *i2, void *data); + +/** * Compares two real numbers of type float. * @param f1 pointer to float one * @param f2 pointer to float two
--- a/src/utils.c Thu May 03 09:26:06 2018 +0200 +++ b/src/utils.c Thu May 03 09:49:38 2018 +0200 @@ -106,6 +106,16 @@ } } +int ucx_longintcmp(const void *i1, const void *i2, void *data) { + int a = *((const long int*) i1); + int b = *((const long int*) i2); + if (a == b) { + return 0; + } else { + return a < b ? -1 : 1; + } +} + int ucx_floatcmp(const void *f1, const void *f2, void *epsilon) { float a = *((const float*) f1); float b = *((const float*) f2);