| 140 #define cxCollectionStoresPointers(c) ((c)->collection.store_pointer) |
140 #define cxCollectionStoresPointers(c) ((c)->collection.store_pointer) |
| 141 |
141 |
| 142 /** |
142 /** |
| 143 * Indicates whether the collection can guarantee that the stored elements are currently sorted. |
143 * Indicates whether the collection can guarantee that the stored elements are currently sorted. |
| 144 * |
144 * |
| 145 * This may return false even when the elements are sorted. |
145 * This may return @c false even when the elements are sorted. |
| 146 * It is totally up to the implementation of the collection whether it keeps track of the order of its elements. |
146 * It is totally up to the implementation of the collection when to check if the elements are sorted. |
| |
147 * It is usually a good practice to establish this property as an invariant that does not need |
| |
148 * to be re-checked on certain operations. |
| 147 * |
149 * |
| 148 * @param c a pointer to a struct that contains #CX_COLLECTION_BASE |
150 * @param c a pointer to a struct that contains #CX_COLLECTION_BASE |
| 149 * @retval true if the elements are currently sorted wrt. the collection's compare function |
151 * @retval true if the elements are currently sorted wrt. the collection's compare function |
| 150 * @retval false if the order of elements is unknown |
152 * @retval false if the order of elements is unknown |
| 151 */ |
153 */ |
| 152 #define cxCollectionSorted(c) ((c)->collection.sorted) |
154 #define cxCollectionSorted(c) ((c)->collection.sorted || (c)->collection.size == 0) |
| |
155 |
| |
156 /** |
| |
157 * Sets the compare function for a collection. |
| |
158 * |
| |
159 * @param c a pointer to a struct that contains #CX_COLLECTION_BASE |
| |
160 * @param func (@c cx_compare_func) the compare function that shall be used by @c c |
| |
161 */ |
| |
162 #define cxCollectionCompareFunc(c, func) (c)->collection.cmpfunc = (func) |
| 153 |
163 |
| 154 /** |
164 /** |
| 155 * Sets a simple destructor function for this collection. |
165 * Sets a simple destructor function for this collection. |
| 156 * |
166 * |
| 157 * @param c a pointer to a struct that contains #CX_COLLECTION_BASE |
167 * @param c a pointer to a struct that contains #CX_COLLECTION_BASE |