|
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 * Copies a string. |
|
13 * @param s the string to copy |
|
14 * @param data omitted |
|
15 * @return a pointer to a copy of s1 that can be passed to free(void*) |
|
16 */ |
|
17 void *ucx_strcpy(void *s, void *data); |
|
18 |
|
19 /** |
|
20 * Copies a memory area. |
|
21 * @param m a pointer to the memory area |
|
22 * @param n a pointer to the size_t containing the size of the memory area |
|
23 * @return a pointer to a copy of the specified memory area that can |
|
24 * be passed to free(void*) |
|
25 */ |
|
26 void *ucx_memcpy(void *m, void *n); |
|
27 |
|
28 /** |
|
29 * Wraps the strcmp function. |
|
30 * @param s1 string one |
|
31 * @param s2 string two |
|
32 * @param data omitted |
|
33 * @return the result of strcmp(s1, s2) |
|
34 */ |
|
35 int ucx_strcmp(void *s1, void *s2, void *data); |
|
36 |
|
37 /** |
|
38 * Wraps the strncmp function. |
|
39 * @param s1 string one |
|
40 * @param s2 string two |
|
41 * @param n a pointer to the size_t containing the third strncmp parameter |
|
42 * @return the result of strncmp(s1, s2, *n) |
|
43 */ |
|
44 int ucx_strncmp(void *s1, void *s2, void *n); |
|
45 |
|
46 /** |
|
47 * Compares two integers of type int. |
|
48 * @param i1 pointer to integer one |
|
49 * @param i2 pointer to integer two |
|
50 * @param data omitted |
|
51 * @return -1, if *i1 is less than *i2, 0 if both are equal, |
|
52 * 1 if *i1 is greater than *i2 |
|
53 */ |
|
54 |
|
55 int ucx_intcmp(void *i1, void *i2, void *data); |
|
56 |
|
57 /** |
|
58 * Compares two real numbers of type float. |
|
59 * @param f1 pointer to float one |
|
60 * @param f2 pointer to float two |
|
61 * @param if provided: a pointer to precision (default: 1e-6f) |
|
62 * @return -1, if *f1 is less than *f2, 0 if both are equal, |
|
63 * 1 if *f1 is greater than *f2 |
|
64 */ |
|
65 |
|
66 int ucx_floatcmp(void *f1, void *f2, void *data); |
|
67 |
|
68 /** |
|
69 * Compares two real numbers of type double. |
|
70 * @param f1 pointer to double one |
|
71 * @param f2 pointer to double two |
|
72 * @param if provided: a pointer to precision (default: 1e-14) |
|
73 * @return -1, if *d1 is less than *d2, 0 if both are equal, |
|
74 * 1 if *d1 is greater than *d2 |
|
75 */ |
|
76 |
|
77 int ucx_doublecmp(void *d1, void *d2, void *data); |
|
78 |
|
79 /** |
|
80 * Compares two pointers. |
|
81 * @param ptr1 pointer one |
|
82 * @param ptr2 pointer two |
|
83 * @param data omitted |
|
84 * @return -1 if ptr1 is less than ptr2, 0 if both are equal, |
|
85 * 1 if ptr1 is greater than ptr2 |
|
86 */ |
|
87 int ucx_ptrcmp(void *ptr1, void *ptr2, void *data); |
|
88 |
|
89 /** |
|
90 * Compares two memory areas. |
|
91 * @param ptr1 pointer one |
|
92 * @param ptr2 pointer two |
|
93 * @param n a pointer to the size_t containing the third parameter for memcmp |
|
94 * @return the result of memcmp(ptr1, ptr2, *n) |
|
95 */ |
|
96 int ucx_memcmp(void *ptr1, void *ptr2, void *n); |
|
97 |
|
98 #ifdef __cplusplus |
|
99 } |
|
100 #endif |
|
101 |
|
102 #endif /* COMPARATOR_H */ |
|
103 |