Thu, 18 Dec 2025 17:50:15 +0100
update ucx
| 174 | 1 | /* |
| 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
| 3 | * | |
| 4 | * Copyright 2023 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 collection.h |
| 30 | * @brief Common definitions for various collection implementations. | |
| 31 | * @author Mike Becker | |
| 32 | * @author Olaf Wintermann | |
| 33 | * @copyright 2-Clause BSD License | |
| 174 | 34 | */ |
| 35 | ||
| 36 | #ifndef UCX_COLLECTION_H | |
| 37 | #define UCX_COLLECTION_H | |
| 38 | ||
| 39 | #include "allocator.h" | |
| 40 | #include "iterator.h" | |
| 324 | 41 | #include "compare.h" |
| 174 | 42 | |
| 43 | #ifdef __cplusplus | |
| 44 | extern "C" { | |
| 45 | #endif | |
| 46 | ||
| 47 | /** | |
| 48 | * Special constant used for creating collections that are storing pointers. | |
| 49 | */ | |
| 50 | #define CX_STORE_POINTERS 0 | |
| 51 | ||
| 52 | /** | |
| 324 | 53 | * Base attributes of a collection. |
| 174 | 54 | */ |
| 324 | 55 | struct cx_collection_s { |
| 56 | /** | |
| 57 | * The allocator to use. | |
| 58 | */ | |
| 59 | const CxAllocator *allocator; | |
| 60 | /** | |
| 61 | * The size of each element. | |
| 62 | */ | |
| 63 | size_t elem_size; | |
| 64 | /** | |
| 65 | * The number of currently stored elements. | |
| 66 | */ | |
| 67 | size_t size; | |
| 68 | /** | |
| 1016 | 69 | * A two-argument comparator function for the elements. |
| 70 | */ | |
| 71 | cx_compare_func simple_cmp; | |
| 72 | /** | |
| 73 | * A three-argument comparator function for the elements. | |
| 74 | * If specified, this function has precedence over the @c simple_cmp function. | |
| 75 | */ | |
| 76 | cx_compare_func2 advanced_cmp; | |
| 77 | /** | |
| 78 | * A pointer to custom data for the @c advanced_cmp function | |
| 79 | */ | |
| 80 | void *cmp_data; | |
| 81 | /** | |
| 324 | 82 | * An optional simple destructor for the collection's elements. |
| 83 | * | |
| 84 | * @attention Read the documentation of the particular collection implementation | |
| 85 | * whether this destructor shall only destroy the contents or also free the memory. | |
| 86 | */ | |
| 87 | cx_destructor_func simple_destructor; | |
| 88 | /** | |
| 89 | * An optional advanced destructor for the collection's elements. | |
| 90 | * | |
| 91 | * @attention Read the documentation of the particular collection implementation | |
| 92 | * whether this destructor shall only destroy the contents or also free the memory. | |
| 93 | */ | |
| 94 | cx_destructor_func2 advanced_destructor; | |
| 95 | /** | |
| 96 | * The pointer to additional data that is passed to the advanced destructor. | |
| 97 | */ | |
| 98 | void *destructor_data; | |
| 99 | /** | |
| 100 | * Indicates if this list is supposed to store pointers | |
| 101 | * instead of copies of the actual objects. | |
| 102 | */ | |
| 103 | bool store_pointer; | |
|
471
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
104 | /** |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
105 | * Indicates if this collection is guaranteed to be sorted. |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
106 | * Note that the elements can still be sorted, even when the collection is not aware of that. |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
107 | */ |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
108 | bool sorted; |
| 324 | 109 | }; |
| 174 | 110 | |
| 111 | /** | |
| 112 | * Use this macro to declare common members for a collection structure. | |
| 440 | 113 | * |
| 114 | * @par Example Use | |
| 115 | * @code | |
| 116 | * struct MyCustomSet { | |
| 117 | * CX_COLLECTION_BASE; | |
| 118 | * MySetElements *data; | |
| 119 | * } | |
| 120 | * @endcode | |
| 174 | 121 | */ |
| 324 | 122 | #define CX_COLLECTION_BASE struct cx_collection_s collection |
| 123 | ||
| 124 | /** | |
|
471
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
125 | * Returns the number of elements currently stored. |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
126 | * |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
127 | * @param c a pointer to a struct that contains #CX_COLLECTION_BASE |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
128 | * @return (@c size_t) the number of currently stored elements |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
129 | */ |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
130 | #define cxCollectionSize(c) ((c)->collection.size) |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
131 | |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
132 | /** |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
133 | * Returns the size of one element. |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
134 | * |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
135 | * If #cxCollectionStoresPointers() returns true, this is the size of a pointer. |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
136 | * |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
137 | * @param c a pointer to a struct that contains #CX_COLLECTION_BASE |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
138 | * @return (@c size_t) the size of one element in bytes |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
139 | */ |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
140 | #define cxCollectionElementSize(c) ((c)->collection.elem_size) |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
141 | |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
142 | /** |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
143 | * Indicates whether this collection only stores pointers instead of the actual data. |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
144 | * |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
145 | * @param c a pointer to a struct that contains #CX_COLLECTION_BASE |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
146 | * @retval true if this collection stores only pointers to data |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
147 | * @retval false if this collection stores the actual element's data |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
148 | */ |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
149 | #define cxCollectionStoresPointers(c) ((c)->collection.store_pointer) |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
150 | |
| 1016 | 151 | |
| 152 | /** | |
| 153 | * Convenience macro for adding indirection to an element if the collection is storing pointers. | |
| 154 | * | |
| 155 | * @param c a pointer to a struct that contains #CX_COLLECTION_BASE | |
| 156 | * @param elem the pointer that shall be taken the address from, if the collection is storing pointers | |
| 157 | * @return if the collection is storing pointers, takes the address of @p elem, otherwise returns @p elem | |
| 158 | */ | |
| 159 | #define cx_ref(c, elem) (cxCollectionStoresPointers(c) ? ((void*)&(elem)) : (elem)) | |
| 160 | ||
| 161 | /** | |
| 162 | * Convenience macro for dereferencing an element if the collection is storing pointers. | |
| 163 | * | |
| 164 | * @param c a pointer to a struct that contains #CX_COLLECTION_BASE | |
| 165 | * @param elem a pointer to the collection element | |
| 166 | * @return if the collection is storing pointers, dereferences @p elem, otherwise returns @p elem | |
| 167 | */ | |
| 168 | #define cx_deref(c, elem) (cxCollectionStoresPointers(c) ? *((void**)(elem)) : (elem)) | |
| 169 | ||
|
471
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
170 | /** |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
171 | * Indicates whether the collection can guarantee that the stored elements are currently sorted. |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
172 | * |
| 845 | 173 | * This may return @c false even when the elements are sorted. |
| 174 | * It is totally up to the implementation of the collection when to check if the elements are sorted. | |
| 175 | * It is usually a good practice to establish this property as an invariant that does not need | |
| 176 | * to be re-checked on certain operations. | |
|
471
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
177 | * |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
178 | * @param c a pointer to a struct that contains #CX_COLLECTION_BASE |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
179 | * @retval true if the elements are currently sorted wrt. the collection's compare function |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
180 | * @retval false if the order of elements is unknown |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
181 | */ |
| 870 | 182 | #define cxCollectionSorted(c) ((c)->collection.sorted || (c)->collection.size == 0) |
|
471
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
183 | |
|
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
440
diff
changeset
|
184 | /** |
| 1016 | 185 | * Sets a simple compare function for a collection. |
| 186 | * | |
| 187 | * Erases a possible advanced compare function. | |
| 188 | * If you want to set both, because you want to access the simple function | |
| 189 | * in your advanced function, you must set the simple function first. | |
| 190 | * | |
| 191 | * @param c a pointer to a struct that contains #CX_COLLECTION_BASE | |
| 192 | * @param func (@c cx_compare_func) the compare function | |
| 193 | */ | |
| 194 | #define cxSetCompareFunc(c, func) \ | |
| 195 | (c)->collection.simple_cmp = (cx_compare_func)(func); \ | |
| 196 | (c)->collection.advanced_cmp = NULL | |
| 197 | ||
| 198 | /** | |
| 199 | * Sets an advanced compare function that supports custom data for a collection. | |
| 200 | * | |
| 201 | * @param c a pointer to a struct that contains #CX_COLLECTION_BASE | |
| 202 | * @param func (@c cx_compare_func2) the compare function | |
| 203 | * @param data (@c void*) the pointer to custom data that is passed to the compare function | |
| 204 | */ | |
| 205 | #define cxSetAdvancedCompareFunc(c, func, data) \ | |
| 206 | (c)->collection.advanced_cmp = (cx_compare_func2) func; \ | |
| 207 | (c)->collection.destructor_data = data | |
| 208 | ||
| 209 | /** | |
| 210 | * Invokes the simple comparator function for two elements. | |
| 211 | * | |
| 212 | * Usually only used by collection implementations. There should be no need | |
| 213 | * to invoke this macro manually. | |
|
943
9b5948aa5b90
update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
870
diff
changeset
|
214 | * |
|
9b5948aa5b90
update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
870
diff
changeset
|
215 | * @param c a pointer to a struct that contains #CX_COLLECTION_BASE |
| 1016 | 216 | * @param left (@c void*) pointer to data |
| 217 | * @param right (@c void*) pointer to data | |
| 218 | */ | |
| 219 | #define cx_invoke_simple_compare_func(c, left, right) \ | |
| 220 | (c)->collection.simple_cmp(left, right) | |
| 221 | ||
| 222 | /** | |
| 223 | * Invokes the advanced comparator function for two elements. | |
| 224 | * | |
| 225 | * Usually only used by collection implementations. There should be no need | |
| 226 | * to invoke this macro manually. | |
| 227 | * | |
| 228 | * @param c a pointer to a struct that contains #CX_COLLECTION_BASE | |
| 229 | * @param left (@c void*) pointer to data | |
| 230 | * @param right (@c void*) pointer to data | |
|
943
9b5948aa5b90
update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
870
diff
changeset
|
231 | */ |
| 1016 | 232 | #define cx_invoke_advanced_compare_func(c, left, right) \ |
| 233 | (c)->collection.advanced_cmp(left, right, (c)->collection.cmp_data) | |
| 234 | ||
| 235 | ||
| 236 | /** | |
| 237 | * Invokes the configured comparator function for two elements. | |
| 238 | * | |
| 239 | * Usually only used by collection implementations. There should be no need | |
| 240 | * to invoke this macro manually. | |
| 241 | * | |
| 242 | * @param c a pointer to a struct that contains #CX_COLLECTION_BASE | |
| 243 | * @param left (@c void*) pointer to data | |
| 244 | * @param right (@c void*) pointer to data | |
| 245 | */ | |
| 246 | #define cx_invoke_compare_func(c, left, right) \ | |
| 247 | (((c)->collection.advanced_cmp) ? \ | |
| 248 | cx_invoke_advanced_compare_func(c,left,right) : \ | |
| 249 | cx_invoke_simple_compare_func(c,left,right)) | |
|
943
9b5948aa5b90
update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
870
diff
changeset
|
250 | |
|
9b5948aa5b90
update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
870
diff
changeset
|
251 | /** |
| 324 | 252 | * Sets a simple destructor function for this collection. |
| 253 | * | |
| 440 | 254 | * @param c a pointer to a struct that contains #CX_COLLECTION_BASE |
| 1016 | 255 | * @param destr (@c cx_destructor_func) the destructor function |
| 324 | 256 | */ |
| 1016 | 257 | #define cxSetDestructor(c, destr) \ |
| 324 | 258 | (c)->collection.simple_destructor = (cx_destructor_func) destr |
| 259 | ||
| 260 | /** | |
| 1016 | 261 | * Sets an advanced destructor function for this collection. |
| 324 | 262 | * |
| 440 | 263 | * @param c a pointer to a struct that contains #CX_COLLECTION_BASE |
| 1016 | 264 | * @param destr (@c cx_destructor_func2) the destructor function |
| 265 | * @param data (@c void*) the additional data the advanced destructor is invoked with | |
| 324 | 266 | */ |
| 1016 | 267 | #define cxSetAdvancedDestructor(c, destr, data) \ |
| 324 | 268 | (c)->collection.advanced_destructor = (cx_destructor_func2) destr; \ |
| 269 | (c)->collection.destructor_data = data | |
| 174 | 270 | |
| 271 | /** | |
| 272 | * Invokes the simple destructor function for a specific element. | |
| 273 | * | |
| 274 | * Usually only used by collection implementations. There should be no need | |
| 275 | * to invoke this macro manually. | |
| 276 | * | |
| 440 | 277 | * When the collection stores pointers, those pointers are directly passed |
| 278 | * to the destructor. Otherwise, a pointer to the element is passed. | |
| 279 | * | |
| 280 | * @param c a pointer to a struct that contains #CX_COLLECTION_BASE | |
| 281 | * @param e the element (the type is @c void* or @c void** depending on context) | |
| 174 | 282 | */ |
| 283 | #define cx_invoke_simple_destructor(c, e) \ | |
| 324 | 284 | (c)->collection.simple_destructor((c)->collection.store_pointer ? (*((void **) (e))) : (e)) |
| 174 | 285 | |
| 286 | /** | |
| 287 | * Invokes the advanced destructor function for a specific element. | |
| 288 | * | |
| 289 | * Usually only used by collection implementations. There should be no need | |
| 290 | * to invoke this macro manually. | |
| 291 | * | |
| 440 | 292 | * When the collection stores pointers, those pointers are directly passed |
| 293 | * to the destructor. Otherwise, a pointer to the element is passed. | |
| 294 | * | |
| 295 | * @param c a pointer to a struct that contains #CX_COLLECTION_BASE | |
| 296 | * @param e the element (the type is @c void* or @c void** depending on context) | |
| 174 | 297 | */ |
| 298 | #define cx_invoke_advanced_destructor(c, e) \ | |
| 324 | 299 | (c)->collection.advanced_destructor((c)->collection.destructor_data, \ |
| 300 | (c)->collection.store_pointer ? (*((void **) (e))) : (e)) | |
| 174 | 301 | |
| 302 | ||
|
187
24ce2c326d85
implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
303 | /** |
|
24ce2c326d85
implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
304 | * Invokes all available destructor functions for a specific element. |
|
24ce2c326d85
implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
305 | * |
|
24ce2c326d85
implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
306 | * Usually only used by collection implementations. There should be no need |
|
24ce2c326d85
implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
307 | * to invoke this macro manually. |
|
24ce2c326d85
implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
308 | * |
| 440 | 309 | * When the collection stores pointers, those pointers are directly passed |
| 310 | * to the destructor. Otherwise, a pointer to the element is passed. | |
| 311 | * | |
| 312 | * @param c a pointer to a struct that contains #CX_COLLECTION_BASE | |
| 313 | * @param e the element (the type is @c void* or @c void** depending on context) | |
|
187
24ce2c326d85
implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
314 | */ |
| 174 | 315 | #define cx_invoke_destructor(c, e) \ |
| 324 | 316 | if ((c)->collection.simple_destructor) cx_invoke_simple_destructor(c,e); \ |
| 317 | if ((c)->collection.advanced_destructor) cx_invoke_advanced_destructor(c,e) | |
| 174 | 318 | |
| 319 | #ifdef __cplusplus | |
| 320 | } // extern "C" | |
| 321 | #endif | |
| 322 | ||
| 323 | #endif // UCX_COLLECTION_H |