ucx/cx/collection.h

changeset 1040
473d8cb58a6c
parent 1016
ccde46662db7
equal deleted inserted replaced
1039:6691e007cef7 1040:473d8cb58a6c
38 38
39 #include "allocator.h" 39 #include "allocator.h"
40 #include "iterator.h" 40 #include "iterator.h"
41 #include "compare.h" 41 #include "compare.h"
42 42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
47 /** 43 /**
48 * Special constant used for creating collections that are storing pointers. 44 * Special constant used for creating collections that are storing pointers.
49 */ 45 */
50 #define CX_STORE_POINTERS 0 46 #define CX_STORE_POINTERS 0
51 47
202 * @param func (@c cx_compare_func2) the compare function 198 * @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 199 * @param data (@c void*) the pointer to custom data that is passed to the compare function
204 */ 200 */
205 #define cxSetAdvancedCompareFunc(c, func, data) \ 201 #define cxSetAdvancedCompareFunc(c, func, data) \
206 (c)->collection.advanced_cmp = (cx_compare_func2) func; \ 202 (c)->collection.advanced_cmp = (cx_compare_func2) func; \
207 (c)->collection.destructor_data = data 203 (c)->collection.cmp_data = data
208 204
209 /** 205 /**
210 * Invokes the simple comparator function for two elements. 206 * Invokes the simple comparator function for two elements.
211 * 207 *
212 * Usually only used by collection implementations. There should be no need 208 * Usually only used by collection implementations. There should be no need
314 */ 310 */
315 #define cx_invoke_destructor(c, e) \ 311 #define cx_invoke_destructor(c, e) \
316 if ((c)->collection.simple_destructor) cx_invoke_simple_destructor(c,e); \ 312 if ((c)->collection.simple_destructor) cx_invoke_simple_destructor(c,e); \
317 if ((c)->collection.advanced_destructor) cx_invoke_advanced_destructor(c,e) 313 if ((c)->collection.advanced_destructor) cx_invoke_advanced_destructor(c,e)
318 314
319 #ifdef __cplusplus 315 /**
320 } // extern "C" 316 * Invokes all available destructor functions for a specific element.
321 #endif 317 *
318 * Usually only used by collection implementations. There should be no need
319 * to invoke this macro manually.
320 *
321 * In contrast to cx_invoke_destructor(), this macro does not automatically
322 * dereference pointers to the elements when cxCollectionStoresPointers()
323 * returns true.
324 *
325 * @param c a pointer to a struct that contains #CX_COLLECTION_BASE
326 * @param e pointer to the element
327 */
328 #define cx_invoke_destructor_raw(c, e) \
329 if ((c)->collection.simple_destructor) (c)->collection.simple_destructor(e); \
330 if ((c)->collection.advanced_destructor) (c)->collection.advanced_destructor((c)->collection.destructor_data, e)
331
322 332
323 #endif // UCX_COLLECTION_H 333 #endif // UCX_COLLECTION_H

mercurial