Wed, 31 Dec 2025 16:40:12 +0100
update ucx to version 4.0
| 174 | 1 | /* |
| 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
| 3 | * | |
| 4 | * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved. | |
| 5 | * | |
| 6 | * Redistribution and use in source and binary forms, with or without | |
| 7 | * modification, are permitted provided that the following conditions are met: | |
| 8 | * | |
| 9 | * 1. Redistributions of source code must retain the above copyright | |
| 10 | * notice, this list of conditions and the following disclaimer. | |
| 11 | * | |
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
| 13 | * notice, this list of conditions and the following disclaimer in the | |
| 14 | * documentation and/or other materials provided with the distribution. | |
| 15 | * | |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
| 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
| 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 26 | * POSSIBILITY OF SUCH DAMAGE. | |
| 27 | */ | |
| 28 | /** | |
| 440 | 29 | * @file compare.h |
| 30 | * @brief A collection of simple compare functions. | |
| 31 | * @author Mike Becker | |
| 32 | * @author Olaf Wintermann | |
| 33 | * @copyright 2-Clause BSD License | |
| 174 | 34 | */ |
| 35 | ||
| 36 | #ifndef UCX_COMPARE_H | |
| 37 | #define UCX_COMPARE_H | |
| 38 | ||
| 39 | #include "common.h" | |
| 40 | ||
|
253
087cc9216f28
initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
41 | /** |
| 440 | 42 | * A comparator function comparing two arbitrary values. |
| 43 | * | |
| 44 | * All functions from compare.h with the cx_cmp prefix are | |
| 45 | * compatible with this signature and can be used as | |
| 845 | 46 | * compare function for collections or other implementations |
| 440 | 47 | * that need to be type-agnostic. |
| 48 | * | |
| 49 | * For simple comparisons the cx_vcmp family of functions | |
| 50 | * can be used, but they are NOT compatible with this function | |
| 51 | * pointer. | |
|
253
087cc9216f28
initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
52 | */ |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
53 | CX_FPTR int (*cx_compare_func)(const void *left, const void *right); |
|
253
087cc9216f28
initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
54 | |
| 174 | 55 | /** |
| 1016 | 56 | * A comparator function comparing two arbitrary values. |
| 57 | * | |
| 58 | * Functions with this signature allow specifying a pointer to custom data. | |
| 59 | */ | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
60 | CX_FPTR int (*cx_compare_func2)(const void *left, const void *right, void *data); |
| 1016 | 61 | |
| 62 | /** | |
| 174 | 63 | * Compares two integers of type int. |
| 64 | * | |
| 440 | 65 | * @note the parameters deliberately have type @c void* to be |
| 66 | * compatible with #cx_compare_func without the need of a cast. | |
| 67 | * | |
| 174 | 68 | * @param i1 pointer to integer one |
| 69 | * @param i2 pointer to integer two | |
| 440 | 70 | * @retval -1 if the left argument is less than the right argument |
| 71 | * @retval 0 if both arguments are equal | |
| 72 | * @retval 1 if the left argument is greater than the right argument | |
| 174 | 73 | */ |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
74 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
75 | int cx_cmp_int(const void *i1, const void *i2); |
| 174 | 76 | |
| 77 | /** | |
|
471
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
78 | * Compares two integers of type int. |
| 440 | 79 | * |
| 80 | * @param i1 integer one | |
| 81 | * @param i2 integer two | |
| 82 | * @retval -1 if the left argument is less than the right argument | |
| 83 | * @retval 0 if both arguments are equal | |
| 84 | * @retval 1 if the left argument is greater than the right argument | |
| 85 | */ | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
86 | CX_EXTERN CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
87 | int cx_vcmp_int(int i1, int i2); |
| 440 | 88 | |
| 89 | /** | |
| 174 | 90 | * Compares two integers of type long int. |
| 91 | * | |
| 440 | 92 | * @note the parameters deliberately have type @c void* to be |
| 93 | * compatible with #cx_compare_func without the need of a cast. | |
| 94 | * | |
| 174 | 95 | * @param i1 pointer to long integer one |
| 96 | * @param i2 pointer to long integer two | |
| 440 | 97 | * @retval -1 if the left argument is less than the right argument |
| 98 | * @retval 0 if both arguments are equal | |
| 99 | * @retval 1 if the left argument is greater than the right argument | |
| 174 | 100 | */ |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
101 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
102 | int cx_cmp_longint(const void *i1, const void *i2); |
| 174 | 103 | |
| 104 | /** | |
|
471
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
105 | * Compares two integers of type long int. |
| 440 | 106 | * |
| 107 | * @param i1 long integer one | |
| 108 | * @param i2 long integer two | |
| 109 | * @retval -1 if the left argument is less than the right argument | |
| 110 | * @retval 0 if both arguments are equal | |
| 111 | * @retval 1 if the left argument is greater than the right argument | |
| 112 | */ | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
113 | CX_EXTERN CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
114 | int cx_vcmp_longint(long int i1, long int i2); |
| 440 | 115 | |
| 116 | /** | |
| 174 | 117 | * Compares two integers of type long long. |
| 118 | * | |
| 440 | 119 | * @note the parameters deliberately have type @c void* to be |
| 120 | * compatible with #cx_compare_func without the need of a cast. | |
| 121 | * | |
| 174 | 122 | * @param i1 pointer to long long one |
| 123 | * @param i2 pointer to long long two | |
| 440 | 124 | * @retval -1 if the left argument is less than the right argument |
| 125 | * @retval 0 if both arguments are equal | |
| 126 | * @retval 1 if the left argument is greater than the right argument | |
| 174 | 127 | */ |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
128 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
129 | int cx_cmp_longlong(const void *i1, const void *i2); |
| 174 | 130 | |
| 131 | /** | |
|
471
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
132 | * Compares two integers of type long long. |
| 440 | 133 | * |
| 134 | * @param i1 long long int one | |
| 135 | * @param i2 long long int two | |
| 136 | * @retval -1 if the left argument is less than the right argument | |
| 137 | * @retval 0 if both arguments are equal | |
| 138 | * @retval 1 if the left argument is greater than the right argument | |
| 139 | */ | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
140 | CX_EXTERN CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
141 | int cx_vcmp_longlong(long long int i1, long long int i2); |
| 440 | 142 | |
| 143 | /** | |
| 174 | 144 | * Compares two integers of type int16_t. |
| 145 | * | |
| 440 | 146 | * @note the parameters deliberately have type @c void* to be |
| 147 | * compatible with #cx_compare_func without the need of a cast. | |
| 148 | * | |
| 174 | 149 | * @param i1 pointer to int16_t one |
| 150 | * @param i2 pointer to int16_t two | |
| 440 | 151 | * @retval -1 if the left argument is less than the right argument |
| 152 | * @retval 0 if both arguments are equal | |
| 153 | * @retval 1 if the left argument is greater than the right argument | |
| 174 | 154 | */ |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
155 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
156 | int cx_cmp_int16(const void *i1, const void *i2); |
| 174 | 157 | |
| 158 | /** | |
| 440 | 159 | * Compares two integers of type int16_t. |
| 160 | * | |
| 161 | * @param i1 int16_t one | |
| 162 | * @param i2 int16_t two | |
| 163 | * @retval -1 if the left argument is less than the right argument | |
| 164 | * @retval 0 if both arguments are equal | |
| 165 | * @retval 1 if the left argument is greater than the right argument | |
| 166 | */ | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
167 | CX_EXTERN CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
168 | int cx_vcmp_int16(int16_t i1, int16_t i2); |
| 440 | 169 | |
| 170 | /** | |
| 174 | 171 | * Compares two integers of type int32_t. |
| 172 | * | |
| 440 | 173 | * @note the parameters deliberately have type @c void* to be |
| 174 | * compatible with #cx_compare_func without the need of a cast. | |
| 175 | * | |
| 174 | 176 | * @param i1 pointer to int32_t one |
| 177 | * @param i2 pointer to int32_t two | |
| 440 | 178 | * @retval -1 if the left argument is less than the right argument |
| 179 | * @retval 0 if both arguments are equal | |
| 180 | * @retval 1 if the left argument is greater than the right argument | |
| 174 | 181 | */ |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
182 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
183 | int cx_cmp_int32(const void *i1, const void *i2); |
| 174 | 184 | |
| 185 | /** | |
| 440 | 186 | * Compares two integers of type int32_t. |
| 187 | * | |
| 188 | * @param i1 int32_t one | |
| 189 | * @param i2 int32_t two | |
| 190 | * @retval -1 if the left argument is less than the right argument | |
| 191 | * @retval 0 if both arguments are equal | |
| 192 | * @retval 1 if the left argument is greater than the right argument | |
| 193 | */ | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
194 | CX_EXTERN CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
195 | int cx_vcmp_int32(int32_t i1, int32_t i2); |
| 440 | 196 | |
| 197 | /** | |
| 174 | 198 | * Compares two integers of type int64_t. |
| 199 | * | |
| 440 | 200 | * @note the parameters deliberately have type @c void* to be |
| 201 | * compatible with #cx_compare_func without the need of a cast. | |
| 202 | * | |
| 174 | 203 | * @param i1 pointer to int64_t one |
| 204 | * @param i2 pointer to int64_t two | |
| 440 | 205 | * @retval -1 if the left argument is less than the right argument |
| 206 | * @retval 0 if both arguments are equal | |
| 207 | * @retval 1 if the left argument is greater than the right argument | |
| 174 | 208 | */ |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
209 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
210 | int cx_cmp_int64(const void *i1, const void *i2); |
| 174 | 211 | |
| 212 | /** | |
| 440 | 213 | * Compares two integers of type int64_t. |
| 214 | * | |
| 215 | * @param i1 int64_t one | |
| 216 | * @param i2 int64_t two | |
| 217 | * @retval -1 if the left argument is less than the right argument | |
| 218 | * @retval 0 if both arguments are equal | |
| 219 | * @retval 1 if the left argument is greater than the right argument | |
| 220 | */ | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
221 | CX_EXTERN CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
222 | int cx_vcmp_int64(int64_t i1, int64_t i2); |
| 440 | 223 | |
| 224 | /** | |
| 174 | 225 | * Compares two integers of type unsigned int. |
| 226 | * | |
| 440 | 227 | * @note the parameters deliberately have type @c void* to be |
| 228 | * compatible with #cx_compare_func without the need of a cast. | |
| 229 | * | |
| 174 | 230 | * @param i1 pointer to unsigned integer one |
| 231 | * @param i2 pointer to unsigned integer two | |
| 440 | 232 | * @retval -1 if the left argument is less than the right argument |
| 233 | * @retval 0 if both arguments are equal | |
| 234 | * @retval 1 if the left argument is greater than the right argument | |
| 174 | 235 | */ |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
236 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
237 | int cx_cmp_uint(const void *i1, const void *i2); |
| 174 | 238 | |
| 239 | /** | |
|
471
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
240 | * Compares two integers of type unsigned int. |
| 440 | 241 | * |
| 242 | * @param i1 unsigned integer one | |
| 243 | * @param i2 unsigned integer two | |
| 244 | * @retval -1 if the left argument is less than the right argument | |
| 245 | * @retval 0 if both arguments are equal | |
| 246 | * @retval 1 if the left argument is greater than the right argument | |
| 247 | */ | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
248 | CX_EXTERN CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
249 | int cx_vcmp_uint(unsigned int i1, unsigned int i2); |
| 440 | 250 | |
| 251 | /** | |
| 174 | 252 | * Compares two integers of type unsigned long int. |
| 253 | * | |
| 440 | 254 | * @note the parameters deliberately have type @c void* to be |
| 255 | * compatible with #cx_compare_func without the need of a cast. | |
| 256 | * | |
| 174 | 257 | * @param i1 pointer to unsigned long integer one |
| 258 | * @param i2 pointer to unsigned long integer two | |
| 440 | 259 | * @retval -1 if the left argument is less than the right argument |
| 260 | * @retval 0 if both arguments are equal | |
| 261 | * @retval 1 if the left argument is greater than the right argument | |
| 174 | 262 | */ |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
263 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
264 | int cx_cmp_ulongint(const void *i1, const void *i2); |
| 174 | 265 | |
| 266 | /** | |
|
471
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
267 | * Compares two integers of type unsigned long int. |
| 440 | 268 | * |
| 269 | * @param i1 unsigned long integer one | |
| 270 | * @param i2 unsigned long integer two | |
| 271 | * @retval -1 if the left argument is less than the right argument | |
| 272 | * @retval 0 if both arguments are equal | |
| 273 | * @retval 1 if the left argument is greater than the right argument | |
| 274 | */ | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
275 | CX_EXTERN CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
276 | int cx_vcmp_ulongint(unsigned long int i1, unsigned long int i2); |
| 440 | 277 | |
| 278 | /** | |
| 174 | 279 | * Compares two integers of type unsigned long long. |
| 280 | * | |
| 440 | 281 | * @note the parameters deliberately have type @c void* to be |
| 282 | * compatible with #cx_compare_func without the need of a cast. | |
| 283 | * | |
| 174 | 284 | * @param i1 pointer to unsigned long long one |
| 285 | * @param i2 pointer to unsigned long long two | |
| 440 | 286 | * @retval -1 if the left argument is less than the right argument |
| 287 | * @retval 0 if both arguments are equal | |
| 288 | * @retval 1 if the left argument is greater than the right argument | |
| 174 | 289 | */ |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
290 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
291 | int cx_cmp_ulonglong(const void *i1, const void *i2); |
| 174 | 292 | |
| 293 | /** | |
|
471
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
294 | * Compares two integers of type unsigned long long. |
| 440 | 295 | * |
| 296 | * @param i1 unsigned long long one | |
| 297 | * @param i2 unsigned long long two | |
| 298 | * @retval -1 if the left argument is less than the right argument | |
| 299 | * @retval 0 if both arguments are equal | |
| 300 | * @retval 1 if the left argument is greater than the right argument | |
| 301 | */ | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
302 | CX_EXTERN CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
303 | int cx_vcmp_ulonglong(unsigned long long int i1, unsigned long long int i2); |
| 440 | 304 | |
| 305 | /** | |
| 174 | 306 | * Compares two integers of type uint16_t. |
| 307 | * | |
| 440 | 308 | * @note the parameters deliberately have type @c void* to be |
| 309 | * compatible with #cx_compare_func without the need of a cast. | |
| 310 | * | |
| 174 | 311 | * @param i1 pointer to uint16_t one |
| 312 | * @param i2 pointer to uint16_t two | |
| 440 | 313 | * @retval -1 if the left argument is less than the right argument |
| 314 | * @retval 0 if both arguments are equal | |
| 315 | * @retval 1 if the left argument is greater than the right argument | |
| 174 | 316 | */ |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
317 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
318 | int cx_cmp_uint16(const void *i1, const void *i2); |
| 174 | 319 | |
| 320 | /** | |
| 440 | 321 | * Compares two integers of type uint16_t. |
| 322 | * | |
| 323 | * @param i1 uint16_t one | |
| 324 | * @param i2 uint16_t two | |
| 325 | * @retval -1 if the left argument is less than the right argument | |
| 326 | * @retval 0 if both arguments are equal | |
| 327 | * @retval 1 if the left argument is greater than the right argument | |
| 328 | */ | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
329 | CX_EXTERN CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
330 | int cx_vcmp_uint16(uint16_t i1, uint16_t i2); |
| 440 | 331 | |
| 332 | /** | |
| 174 | 333 | * Compares two integers of type uint32_t. |
| 334 | * | |
| 440 | 335 | * @note the parameters deliberately have type @c void* to be |
| 336 | * compatible with #cx_compare_func without the need of a cast. | |
| 337 | * | |
| 174 | 338 | * @param i1 pointer to uint32_t one |
| 339 | * @param i2 pointer to uint32_t two | |
| 440 | 340 | * @retval -1 if the left argument is less than the right argument |
| 341 | * @retval 0 if both arguments are equal | |
| 342 | * @retval 1 if the left argument is greater than the right argument | |
| 174 | 343 | */ |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
344 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
345 | int cx_cmp_uint32(const void *i1, const void *i2); |
| 174 | 346 | |
| 347 | /** | |
| 440 | 348 | * Compares two integers of type uint32_t. |
| 349 | * | |
| 350 | * @param i1 uint32_t one | |
| 351 | * @param i2 uint32_t two | |
| 352 | * @retval -1 if the left argument is less than the right argument | |
| 353 | * @retval 0 if both arguments are equal | |
| 354 | * @retval 1 if the left argument is greater than the right argument | |
| 355 | */ | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
356 | CX_EXTERN CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
357 | int cx_vcmp_uint32(uint32_t i1, uint32_t i2); |
| 440 | 358 | |
| 359 | /** | |
| 174 | 360 | * Compares two integers of type uint64_t. |
| 361 | * | |
| 440 | 362 | * @note the parameters deliberately have type @c void* to be |
| 363 | * compatible with #cx_compare_func without the need of a cast. | |
| 364 | * | |
| 174 | 365 | * @param i1 pointer to uint64_t one |
| 366 | * @param i2 pointer to uint64_t two | |
| 440 | 367 | * @retval -1 if the left argument is less than the right argument |
| 368 | * @retval 0 if both arguments are equal | |
| 369 | * @retval 1 if the left argument is greater than the right argument | |
| 174 | 370 | */ |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
371 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
372 | int cx_cmp_uint64(const void *i1, const void *i2); |
| 174 | 373 | |
| 374 | /** | |
| 440 | 375 | * Compares two integers of type uint64_t. |
| 376 | * | |
| 377 | * @param i1 uint64_t one | |
| 378 | * @param i2 uint64_t two | |
| 379 | * @retval -1 if the left argument is less than the right argument | |
| 380 | * @retval 0 if both arguments are equal | |
| 381 | * @retval 1 if the left argument is greater than the right argument | |
| 382 | */ | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
383 | CX_EXTERN CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
384 | int cx_vcmp_uint64(uint64_t i1, uint64_t i2); |
| 440 | 385 | |
| 386 | /** | |
| 845 | 387 | * Compares two integers of type size_t. |
| 388 | * | |
| 389 | * @note the parameters deliberately have type @c void* to be | |
| 390 | * compatible with #cx_compare_func without the need of a cast. | |
| 391 | * | |
| 392 | * @param i1 pointer to size_t one | |
| 393 | * @param i2 pointer to size_t two | |
| 394 | * @retval -1 if the left argument is less than the right argument | |
| 395 | * @retval 0 if both arguments are equal | |
| 396 | * @retval 1 if the left argument is greater than the right argument | |
| 397 | */ | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
398 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
399 | int cx_cmp_size(const void *i1, const void *i2); |
| 845 | 400 | |
| 401 | /** | |
| 402 | * Compares two integers of type size_t. | |
| 403 | * | |
| 404 | * @param i1 size_t one | |
| 405 | * @param i2 size_t two | |
| 406 | * @retval -1 if the left argument is less than the right argument | |
| 407 | * @retval 0 if both arguments are equal | |
| 408 | * @retval 1 if the left argument is greater than the right argument | |
| 409 | */ | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
410 | CX_EXTERN CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
411 | int cx_vcmp_size(size_t i1, size_t i2); |
| 845 | 412 | |
| 413 | /** | |
| 174 | 414 | * Compares two real numbers of type float with precision 1e-6f. |
| 415 | * | |
| 440 | 416 | * @note the parameters deliberately have type @c void* to be |
| 417 | * compatible with #cx_compare_func without the need of a cast. | |
| 418 | * | |
| 174 | 419 | * @param f1 pointer to float one |
| 420 | * @param f2 pointer to float two | |
| 440 | 421 | * @retval -1 if the left argument is less than the right argument |
| 422 | * @retval 0 if both arguments are equal | |
| 423 | * @retval 1 if the left argument is greater than the right argument | |
| 174 | 424 | */ |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
425 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
426 | int cx_cmp_float(const void *f1, const void *f2); |
| 174 | 427 | |
| 440 | 428 | /** |
| 429 | * Compares two real numbers of type float with precision 1e-6f. | |
| 430 | * | |
| 431 | * @param f1 float one | |
| 432 | * @param f2 float two | |
| 433 | * @retval -1 if the left argument is less than the right argument | |
| 434 | * @retval 0 if both arguments are equal | |
| 435 | * @retval 1 if the left argument is greater than the right argument | |
| 436 | */ | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
437 | CX_EXTERN CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
438 | int cx_vcmp_float(float f1, float f2); |
| 174 | 439 | |
| 440 | /** | |
| 441 | * Compares two real numbers of type double with precision 1e-14. | |
| 442 | * | |
| 440 | 443 | * @note the parameters deliberately have type @c void* to be |
| 444 | * compatible with #cx_compare_func without the need of a cast. | |
| 445 | * | |
| 174 | 446 | * @param d1 pointer to double one |
| 447 | * @param d2 pointer to double two | |
| 440 | 448 | * @retval -1 if the left argument is less than the right argument |
| 449 | * @retval 0 if both arguments are equal | |
| 450 | * @retval 1 if the left argument is greater than the right argument | |
| 174 | 451 | */ |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
452 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
453 | int cx_cmp_double(const void *d1, const void *d2); |
| 440 | 454 | |
| 455 | /** | |
|
471
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
456 | * Compares two real numbers of type double with precision 1e-14. |
| 440 | 457 | * |
| 458 | * @param d1 double one | |
| 459 | * @param d2 double two | |
| 460 | * @retval -1 if the left argument is less than the right argument | |
| 461 | * @retval 0 if both arguments are equal | |
| 462 | * @retval 1 if the left argument is greater than the right argument | |
| 463 | */ | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
464 | CX_EXTERN CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
465 | int cx_vcmp_double(double d1, double d2); |
| 174 | 466 | |
| 467 | /** | |
| 468 | * Compares the integer representation of two pointers. | |
| 469 | * | |
| 440 | 470 | * @note the parameters deliberately have type @c void* to be |
| 471 | * compatible with #cx_compare_func without the need of a cast. | |
| 472 | * | |
| 324 | 473 | * @param ptr1 pointer to pointer one (const intptr_t*) |
| 474 | * @param ptr2 pointer to pointer two (const intptr_t*) | |
| 440 | 475 | * @retval -1 if the left argument is less than the right argument |
| 476 | * @retval 0 if both arguments are equal | |
| 477 | * @retval 1 if the left argument is greater than the right argument | |
| 174 | 478 | */ |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
479 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
480 | int cx_cmp_intptr(const void *ptr1, const void *ptr2); |
| 440 | 481 | |
| 482 | /** | |
| 483 | * Compares the integer representation of two pointers. | |
| 484 | * | |
| 485 | * @param ptr1 pointer one | |
| 486 | * @param ptr2 pointer two | |
| 487 | * @retval -1 if the left argument is less than the right argument | |
| 488 | * @retval 0 if both arguments are equal | |
| 489 | * @retval 1 if the left argument is greater than the right argument | |
| 490 | */ | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
491 | CX_EXTERN CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
492 | int cx_vcmp_intptr(intptr_t ptr1, intptr_t ptr2); |
| 174 | 493 | |
| 494 | /** | |
| 495 | * Compares the unsigned integer representation of two pointers. | |
| 496 | * | |
| 440 | 497 | * @note the parameters deliberately have type @c void* to be |
| 498 | * compatible with #cx_compare_func without the need of a cast. | |
| 499 | * | |
| 324 | 500 | * @param ptr1 pointer to pointer one (const uintptr_t*) |
| 501 | * @param ptr2 pointer to pointer two (const uintptr_t*) | |
| 440 | 502 | * @retval -1 if the left argument is less than the right argument |
| 503 | * @retval 0 if both arguments are equal | |
| 504 | * @retval 1 if the left argument is greater than the right argument | |
| 174 | 505 | */ |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
506 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
507 | int cx_cmp_uintptr(const void *ptr1, const void *ptr2); |
| 440 | 508 | |
| 509 | /** | |
| 510 | * Compares the unsigned integer representation of two pointers. | |
| 511 | * | |
| 512 | * @param ptr1 pointer one | |
| 513 | * @param ptr2 pointer two | |
| 514 | * @retval -1 if the left argument is less than the right argument | |
| 515 | * @retval 0 if both arguments are equal | |
| 516 | * @retval 1 if the left argument is greater than the right argument | |
| 517 | */ | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
518 | CX_EXTERN CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
519 | int cx_vcmp_uintptr(uintptr_t ptr1, uintptr_t ptr2); |
| 174 | 520 | |
|
253
087cc9216f28
initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
521 | /** |
|
471
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
522 | * Compares the pointers specified in the arguments without dereferencing. |
|
253
087cc9216f28
initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
523 | * |
|
087cc9216f28
initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
524 | * @param ptr1 pointer one |
|
087cc9216f28
initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
525 | * @param ptr2 pointer two |
| 440 | 526 | * @retval -1 if the left argument is less than the right argument |
| 527 | * @retval 0 if both arguments are equal | |
| 528 | * @retval 1 if the left argument is greater than the right argument | |
|
253
087cc9216f28
initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
529 | */ |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
530 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
531 | int cx_cmp_ptr(const void *ptr1, const void *ptr2); |
|
253
087cc9216f28
initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
532 | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
533 | /** Wraps a compare function for cx_cmp_wrap. */ |
| 1016 | 534 | typedef struct { |
| 535 | /** The wrapped compare function */ | |
| 536 | cx_compare_func cmp; | |
| 537 | } cx_compare_func_wrapper; | |
| 538 | ||
| 539 | /** | |
| 540 | * A @c cx_compare_func2 wrapper for a @c cx_compare_func(). | |
| 541 | * | |
| 542 | * @param ptr1 pointer one | |
| 543 | * @param ptr2 pointer two | |
| 544 | * @param cmp_wrapper a pointer to a @c cx_compare_func_wrapper | |
| 545 | * @return the result of the invoked compare function | |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
546 | * @see cx_compare_func_wrapper |
| 1016 | 547 | */ |
|
1040
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
548 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
473d8cb58a6c
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1016
diff
changeset
|
549 | int cx_cmp_wrap(const void *ptr1, const void *ptr2, void* cmp_wrapper); |
| 174 | 550 | |
| 551 | #endif //UCX_COMPARE_H |