278 * respective elements are stored. |
278 * respective elements are stored. |
279 * |
279 * |
280 * @note An iterator iterates over all elements successively. Therefore, the order |
280 * @note An iterator iterates over all elements successively. Therefore, the order |
281 * highly depends on the map implementation and may change arbitrarily when the contents change. |
281 * highly depends on the map implementation and may change arbitrarily when the contents change. |
282 * |
282 * |
283 * @param map the map to create the iterator for |
283 * @param map the map to create the iterator for (can be @c NULL) |
284 * @return an iterator for the currently stored values |
284 * @return an iterator for the currently stored values |
285 */ |
285 */ |
286 cx_attr_nonnull |
|
287 cx_attr_nodiscard |
286 cx_attr_nodiscard |
288 static inline CxMapIterator cxMapIteratorValues(const CxMap *map) { |
287 static inline CxMapIterator cxMapIteratorValues(const CxMap *map) { |
|
288 if (map == NULL) map = cxEmptyMap; |
289 return map->cl->iterator(map, CX_MAP_ITERATOR_VALUES); |
289 return map->cl->iterator(map, CX_MAP_ITERATOR_VALUES); |
290 } |
290 } |
291 |
291 |
292 /** |
292 /** |
293 * Creates a key iterator for a map. |
293 * Creates a key iterator for a map. |
296 * during iterator shall be treated as @c const @c CxHashKey* . |
296 * during iterator shall be treated as @c const @c CxHashKey* . |
297 * |
297 * |
298 * @note An iterator iterates over all elements successively. Therefore, the order |
298 * @note An iterator iterates over all elements successively. Therefore, the order |
299 * highly depends on the map implementation and may change arbitrarily when the contents change. |
299 * highly depends on the map implementation and may change arbitrarily when the contents change. |
300 * |
300 * |
301 * @param map the map to create the iterator for |
301 * @param map the map to create the iterator for (can be @c NULL) |
302 * @return an iterator for the currently stored keys |
302 * @return an iterator for the currently stored keys |
303 */ |
303 */ |
304 cx_attr_nonnull |
|
305 cx_attr_nodiscard |
304 cx_attr_nodiscard |
306 static inline CxMapIterator cxMapIteratorKeys(const CxMap *map) { |
305 static inline CxMapIterator cxMapIteratorKeys(const CxMap *map) { |
|
306 if (map == NULL) map = cxEmptyMap; |
307 return map->cl->iterator(map, CX_MAP_ITERATOR_KEYS); |
307 return map->cl->iterator(map, CX_MAP_ITERATOR_KEYS); |
308 } |
308 } |
309 |
309 |
310 /** |
310 /** |
311 * Creates an iterator for a map. |
311 * Creates an iterator for a map. |
314 * during iterator shall be treated as @c const @c CxMapEntry* . |
314 * during iterator shall be treated as @c const @c CxMapEntry* . |
315 * |
315 * |
316 * @note An iterator iterates over all elements successively. Therefore, the order |
316 * @note An iterator iterates over all elements successively. Therefore, the order |
317 * highly depends on the map implementation and may change arbitrarily when the contents change. |
317 * highly depends on the map implementation and may change arbitrarily when the contents change. |
318 * |
318 * |
319 * @param map the map to create the iterator for |
319 * @param map the map to create the iterator for (can be @c NULL) |
320 * @return an iterator for the currently stored entries |
320 * @return an iterator for the currently stored entries |
321 * @see cxMapIteratorKeys() |
321 * @see cxMapIteratorKeys() |
322 * @see cxMapIteratorValues() |
322 * @see cxMapIteratorValues() |
323 */ |
323 */ |
324 cx_attr_nonnull |
|
325 cx_attr_nodiscard |
324 cx_attr_nodiscard |
326 static inline CxMapIterator cxMapIterator(const CxMap *map) { |
325 static inline CxMapIterator cxMapIterator(const CxMap *map) { |
|
326 if (map == NULL) map = cxEmptyMap; |
327 return map->cl->iterator(map, CX_MAP_ITERATOR_PAIRS); |
327 return map->cl->iterator(map, CX_MAP_ITERATOR_PAIRS); |
328 } |
328 } |
329 |
329 |
330 |
330 |
331 /** |
331 /** |
336 * respective elements are stored. |
336 * respective elements are stored. |
337 * |
337 * |
338 * @note An iterator iterates over all elements successively. Therefore, the order |
338 * @note An iterator iterates over all elements successively. Therefore, the order |
339 * highly depends on the map implementation and may change arbitrarily when the contents change. |
339 * highly depends on the map implementation and may change arbitrarily when the contents change. |
340 * |
340 * |
341 * @param map the map to create the iterator for |
341 * @param map the map to create the iterator for (can be @c NULL) |
342 * @return an iterator for the currently stored values |
342 * @return an iterator for the currently stored values |
343 */ |
343 */ |
344 cx_attr_nonnull |
|
345 cx_attr_nodiscard |
344 cx_attr_nodiscard |
346 cx_attr_export |
345 cx_attr_export |
347 CxMapIterator cxMapMutIteratorValues(CxMap *map); |
346 CxMapIterator cxMapMutIteratorValues(CxMap *map); |
348 |
347 |
349 /** |
348 /** |
353 * during iterator shall be treated as @c const @c CxHashKey* . |
352 * during iterator shall be treated as @c const @c CxHashKey* . |
354 * |
353 * |
355 * @note An iterator iterates over all elements successively. Therefore, the order |
354 * @note An iterator iterates over all elements successively. Therefore, the order |
356 * highly depends on the map implementation and may change arbitrarily when the contents change. |
355 * highly depends on the map implementation and may change arbitrarily when the contents change. |
357 * |
356 * |
358 * @param map the map to create the iterator for |
357 * @param map the map to create the iterator for (can be @c NULL) |
359 * @return an iterator for the currently stored keys |
358 * @return an iterator for the currently stored keys |
360 */ |
359 */ |
361 cx_attr_nonnull |
|
362 cx_attr_nodiscard |
360 cx_attr_nodiscard |
363 cx_attr_export |
361 cx_attr_export |
364 CxMapIterator cxMapMutIteratorKeys(CxMap *map); |
362 CxMapIterator cxMapMutIteratorKeys(CxMap *map); |
365 |
363 |
366 /** |
364 /** |
370 * during iterator shall be treated as @c const @c CxMapEntry* . |
368 * during iterator shall be treated as @c const @c CxMapEntry* . |
371 * |
369 * |
372 * @note An iterator iterates over all elements successively. Therefore, the order |
370 * @note An iterator iterates over all elements successively. Therefore, the order |
373 * highly depends on the map implementation and may change arbitrarily when the contents change. |
371 * highly depends on the map implementation and may change arbitrarily when the contents change. |
374 * |
372 * |
375 * @param map the map to create the iterator for |
373 * @param map the map to create the iterator for (can be @c NULL) |
376 * @return an iterator for the currently stored entries |
374 * @return an iterator for the currently stored entries |
377 * @see cxMapMutIteratorKeys() |
375 * @see cxMapMutIteratorKeys() |
378 * @see cxMapMutIteratorValues() |
376 * @see cxMapMutIteratorValues() |
379 */ |
377 */ |
380 cx_attr_nonnull |
|
381 cx_attr_nodiscard |
378 cx_attr_nodiscard |
382 cx_attr_export |
379 cx_attr_export |
383 CxMapIterator cxMapMutIterator(CxMap *map); |
380 CxMapIterator cxMapMutIterator(CxMap *map); |
384 |
381 |
385 #ifdef __cplusplus |
382 #ifdef __cplusplus |