ucx/comparator.h

Wed, 27 Feb 2013 10:57:40 +0100

author
Mike Becker <universe@uap-core.de>
date
Wed, 27 Feb 2013 10:57:40 +0100
changeset 92
7625a8efcc97
parent 91
91595a45fad6
permissions
-rw-r--r--

added floating point comparators

universe@89 1 #ifndef COMPARATOR_H
universe@89 2 #define COMPARATOR_H
universe@89 3
universe@89 4 #ifdef __cplusplus
universe@89 5 extern "C" {
universe@89 6 #endif
universe@89 7
universe@89 8 #include "ucx.h"
universe@89 9 #include <string.h>
universe@89 10
universe@89 11 /**
universe@89 12 * Wraps the strcmp function.
universe@89 13 * @param s1 string one
universe@89 14 * @param s2 string two
universe@89 15 * @param data omitted
universe@89 16 * @return the result of strcmp(s1, s2)
universe@89 17 */
universe@89 18 int ucx_strcmp(void *s1, void *s2, void *data);
universe@89 19
universe@89 20 /**
universe@89 21 * Wraps the strncmp function.
universe@89 22 * @param s1 string one
universe@89 23 * @param s2 string two
universe@89 24 * @param n a pointer to the size_t containing the third strncmp parameter
universe@89 25 * @return the result of strncmp(s1, s2, *n)
universe@89 26 */
universe@89 27 int ucx_strncmp(void *s1, void *s2, void *n);
universe@89 28
universe@89 29 /**
universe@89 30 * Compares two integers of type int.
universe@89 31 * @param i1 pointer to integer one
universe@89 32 * @param i2 pointer to integer two
universe@89 33 * @param data omitted
universe@89 34 * @return -1, if *i1 is less than *i2, 0 if both are equal,
universe@89 35 * 1 if *i1 is greater than *i2
universe@89 36 */
universe@89 37
universe@89 38 int ucx_intcmp(void *i1, void *i2, void *data);
universe@89 39
universe@89 40 /**
universe@92 41 * Compares two real numbers of type float.
universe@92 42 * @param f1 pointer to float one
universe@92 43 * @param f2 pointer to float two
universe@92 44 * @param if provided: a pointer to precision (default: 1e-6f)
universe@92 45 * @return -1, if *f1 is less than *f2, 0 if both are equal,
universe@92 46 * 1 if *f1 is greater than *f2
universe@92 47 */
universe@92 48
universe@92 49 int ucx_floatcmp(void *f1, void *f2, void *data);
universe@92 50
universe@92 51 /**
universe@92 52 * Compares two real numbers of type double.
universe@92 53 * @param f1 pointer to double one
universe@92 54 * @param f2 pointer to double two
universe@92 55 * @param if provided: a pointer to precision (default: 1e-14)
universe@92 56 * @return -1, if *d1 is less than *d2, 0 if both are equal,
universe@92 57 * 1 if *d1 is greater than *d2
universe@92 58 */
universe@92 59
universe@92 60 int ucx_doublecmp(void *d1, void *d2, void *data);
universe@92 61
universe@92 62 /**
universe@89 63 * Compares two pointers.
universe@89 64 * @param ptr1 pointer one
universe@89 65 * @param ptr2 pointer two
universe@89 66 * @param data omitted
universe@89 67 * @return -1 if ptr1 is less than ptr2, 0 if both are equal,
universe@89 68 * 1 if ptr1 is greater than ptr2
universe@89 69 */
universe@89 70 int ucx_ptrcmp(void *ptr1, void *ptr2, void *data);
universe@89 71
universe@91 72 /**
universe@91 73 * Compares two memory areas.
universe@91 74 * @param ptr1 pointer one
universe@91 75 * @param ptr2 pointer two
universe@91 76 * @param n a pointer to the size_t containing the third parameter for memcmp
universe@91 77 * @return the result of memcmp(ptr1, ptr2, *n)
universe@91 78 */
universe@91 79 int ucx_memcmp(void *ptr1, void *ptr2, void *n);
universe@91 80
universe@89 81 #ifdef __cplusplus
universe@89 82 }
universe@89 83 #endif
universe@89 84
universe@89 85 #endif /* COMPARATOR_H */
universe@89 86

mercurial