src/cx/map.h

changeset 1429
6e0c3a8a914a
parent 1426
3a89b31f0724
equal deleted inserted replaced
1428:0ac4aa1737fd 1429:6e0c3a8a914a
109 CX_ITERATOR_BASE; 109 CX_ITERATOR_BASE;
110 110
111 /** 111 /**
112 * Handle for the source map. 112 * Handle for the source map.
113 */ 113 */
114 union { 114 CxMap *map;
115 /**
116 * Access for mutating iterators.
117 */
118 CxMap *m;
119 /**
120 * Access for normal iterators.
121 */
122 const CxMap *c;
123 } map;
124 115
125 /** 116 /**
126 * Handle for the current element. 117 * Handle for the current element.
127 * 118 *
128 * @attention Depends on the map implementation, do not assume a type (better: do not use!). 119 * @attention Depends on the map implementation, do not assume a type (better: do not use!).
300 */ 291 */
301 cx_attr_nodiscard 292 cx_attr_nodiscard
302 CX_EXPORT CxMapIterator cxMapIterator(const CxMap *map); 293 CX_EXPORT CxMapIterator cxMapIterator(const CxMap *map);
303 294
304 /** 295 /**
305 * Creates a mutating iterator over the values of a map.
306 *
307 * When the map is storing pointers, those pointers are returned.
308 * Otherwise, the iterator iterates over pointers to the memory within the map where the
309 * respective elements are stored.
310 *
311 * @note An iterator iterates over all elements successively. Therefore, the order
312 * highly depends on the map implementation and may change arbitrarily when the contents change.
313 *
314 * @param map the map to create the iterator for (can be @c NULL)
315 * @return an iterator for the currently stored values
316 */
317 cx_attr_nodiscard
318 CX_EXPORT CxMapIterator cxMapMutIteratorValues(CxMap *map);
319
320 /**
321 * Creates a mutating iterator over the keys of a map.
322 *
323 * The elements of the iterator are keys of type CxHashKey, and the pointer returned
324 * during iterator shall be treated as @c const @c CxHashKey* .
325 *
326 * @note An iterator iterates over all elements successively. Therefore, the order
327 * highly depends on the map implementation and may change arbitrarily when the contents change.
328 *
329 * @param map the map to create the iterator for (can be @c NULL)
330 * @return an iterator for the currently stored keys
331 */
332 cx_attr_nodiscard
333 CX_EXPORT CxMapIterator cxMapMutIteratorKeys(CxMap *map);
334
335 /**
336 * Creates a mutating iterator for a map.
337 *
338 * The elements of the iterator are key/value pairs of type CxMapEntry, and the pointer returned
339 * during iterator shall be treated as @c const @c CxMapEntry* .
340 *
341 * @note An iterator iterates over all elements successively. Therefore, the order
342 * highly depends on the map implementation and may change arbitrarily when the contents change.
343 *
344 * @param map the map to create the iterator for (can be @c NULL)
345 * @return an iterator for the currently stored entries
346 * @see cxMapMutIteratorKeys()
347 * @see cxMapMutIteratorValues()
348 */
349 cx_attr_nodiscard
350 CX_EXPORT CxMapIterator cxMapMutIterator(CxMap *map);
351
352 /**
353 * Puts a key/value-pair into the map. 296 * Puts a key/value-pair into the map.
354 * 297 *
355 * A possible existing value will be overwritten. 298 * A possible existing value will be overwritten.
356 * If destructor functions are specified, they are called for 299 * If destructor functions are specified, they are called for
357 * the overwritten element. 300 * the overwritten element.

mercurial