adds ucx_longintcmp() compare function

Thu, 03 May 2018 09:49:38 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 03 May 2018 09:49:38 +0200
changeset 285
7be3ae7ffb58
parent 284
d7e43c4b2992
child 286
85f55abea563

adds ucx_longintcmp() compare function

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:26:06 2018 +0200
     1.2 +++ b/src/ucx/utils.h	Thu May 03 09:49:38 2018 +0200
     1.3 @@ -166,6 +166,16 @@
     1.4  int ucx_intcmp(const void *i1, const void *i2, void *data);
     1.5  
     1.6  /**
     1.7 + * Compares two integers of type long int.
     1.8 + * @param i1 pointer to long integer one
     1.9 + * @param i2 pointer to long integer two
    1.10 + * @param data omitted
    1.11 + * @return -1, if *i1 is less than *i2, 0 if both are equal,
    1.12 + * 1 if *i1 is greater than *i2
    1.13 + */
    1.14 +int ucx_longintcmp(const void *i1, const void *i2, void *data);
    1.15 +
    1.16 +/**
    1.17   * Compares two real numbers of type float.
    1.18   * @param f1 pointer to float one
    1.19   * @param f2 pointer to float two
     2.1 --- a/src/utils.c	Thu May 03 09:26:06 2018 +0200
     2.2 +++ b/src/utils.c	Thu May 03 09:49:38 2018 +0200
     2.3 @@ -106,6 +106,16 @@
     2.4     }
     2.5  }
     2.6  
     2.7 +int ucx_longintcmp(const void *i1, const void *i2, void *data) {
     2.8 +   int a = *((const long int*) i1);
     2.9 +   int b = *((const long int*) i2);
    2.10 +   if (a == b) {
    2.11 +       return 0;
    2.12 +   } else {
    2.13 +       return a < b ? -1 : 1;
    2.14 +   }
    2.15 +}
    2.16 +
    2.17  int ucx_floatcmp(const void *f1, const void *f2, void *epsilon) {
    2.18     float a = *((const float*) f1);
    2.19     float b = *((const float*) f2);

mercurial