ucx/comparator.h

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

mercurial