| 42 cxCollectionSorted(c) |
42 cxCollectionSorted(c) |
| 43 ``` |
43 ``` |
| 44 |
44 |
| 45 In each case the argument `c` is a pointer to your collection. The macro will then access the base data with `c->collection`. |
45 In each case the argument `c` is a pointer to your collection. The macro will then access the base data with `c->collection`. |
| 46 |
46 |
| |
47 ## Destructor Functions |
| |
48 |
| 47 For working with destructors, the following macros are defined: |
49 For working with destructors, the following macros are defined: |
| 48 |
50 |
| 49 ```C |
51 ```C |
| 50 cxDefineDestructor(c, destr) |
52 cxDefineDestructor(c, destr) |
| 51 cxDefineAdvancedDestructor(c, destr, data) |
53 cxDefineAdvancedDestructor(c, destr, data) |
| 65 Your collection _should_ be supporting destructors by invoking `cx_invoke_destructor()` whenever an element |
67 Your collection _should_ be supporting destructors by invoking `cx_invoke_destructor()` whenever an element |
| 66 is removed from your collection _without_ being returned to the caller. |
68 is removed from your collection _without_ being returned to the caller. |
| 67 This macro will invoke a simple destructor, if one is assigned, first, and then the advanced destructor (again, if assigned). |
69 This macro will invoke a simple destructor, if one is assigned, first, and then the advanced destructor (again, if assigned). |
| 68 |
70 |
| 69 > Destructor functions are always invoked with a pointer to the element in your collection. |
71 > Destructor functions are always invoked with a pointer to the element in your collection. |
| 70 > If your collection is storing pointers (i.e. `cxCollectionStorePointers()` returns `true`) |
72 > If your collection is storing pointers (i.e. `cxCollectionStoresPointers()` returns `true`) |
| 71 > the `cx_invoke_destructor()` will make sure that the pointer to the element is dereferenced first, |
73 > the `cx_invoke_destructor()` will make sure that the pointer to the element is dereferenced first, |
| 72 > so that the destructor functions are _always_ invoked with pointer to the actual element. |
74 > so that the destructor functions are _always_ invoked with pointer to the actual element. |
| 73 {style="note"} |
75 {style="note"} |
| 74 |
76 |
| 75 <seealso> |
77 <seealso> |