|
10 | 10 | * Copyright (c) 2004-2005 The Regents of the University of California.
|
11 | 11 | * All rights reserved.
|
12 | 12 | * Copyright (c) 2015-2016 Intel, Inc. All rights reserved.
|
13 |
| - * Copyright (c) 2015 Research Organization for Information Science |
| 13 | + * Copyright (c) 2015-2016 Research Organization for Information Science |
14 | 14 | * and Technology (RIST). All rights reserved.
|
15 | 15 | * Copyright (c) 2016 Mellanox Technologies, Inc.
|
16 | 16 | * All rights reserved.
|
@@ -371,6 +371,29 @@ static inline int pmix_next_poweroftwo(int value)
|
371 | 371 | }
|
372 | 372 |
|
373 | 373 |
|
| 374 | +/** |
| 375 | + * Loop over a hash table. |
| 376 | + * |
| 377 | + * @param[in] key Key for each item |
| 378 | + * @param[in] type Type of key (ui32|ui64|ptr) |
| 379 | + * @param[in] value Storage for each item |
| 380 | + * @param[in] ht Hash table to iterate over |
| 381 | + * |
| 382 | + * This macro provides a simple way to loop over the items in a pmix_hash_table_t. It |
| 383 | + * is not safe to call pmix_hash_table_remove* from within the loop. |
| 384 | + * |
| 385 | + * Example Usage: |
| 386 | + * |
| 387 | + * uint64_t key; |
| 388 | + * void * value; |
| 389 | + * PMIX_HASH_TABLE_FOREACH(key, uint64, value, ht) { |
| 390 | + * do_something(key, value); |
| 391 | + * } |
| 392 | + */ |
| 393 | +#define PMIX_HASH_TABLE_FOREACH(key, type, value, ht) \ |
| 394 | + for (void *_nptr=NULL; \ |
| 395 | + PMIX_SUCCESS == pmix_hash_table_get_next_key_##type(ht, &key, (void **)&value, _nptr, &_nptr);) |
| 396 | + |
374 | 397 | END_C_DECLS
|
375 | 398 |
|
376 | 399 | #endif /* PMIX_HASH_TABLE_H */
|
0 commit comments