|
14 | 14 | * Copyright (c) 2014-2015 Mellanox Technologies, Inc.
|
15 | 15 | * All rights reserved.
|
16 | 16 | * Copyright (c) 2014 Intel, Inc. All rights reserved.
|
17 |
| - * Copyright (c) 2014 Research Organization for Information Science |
| 17 | + * Copyright (c) 2014-2016 Research Organization for Information Science |
18 | 18 | * and Technology (RIST). All rights reserved.
|
19 | 19 | * $COPYRIGHT$
|
20 | 20 | *
|
@@ -463,6 +463,28 @@ OPAL_DECLSPEC int opal_proc_table_get_next_key(opal_proc_table_t *pt, opal_proce
|
463 | 463 | void **value, void *in_node1, void **out_node1,
|
464 | 464 | void *in_node2, void **out_node2);
|
465 | 465 |
|
| 466 | +/** |
| 467 | + * Loop over a hash table. |
| 468 | + * |
| 469 | + * @param[in] key Key for each item |
| 470 | + * @param[in] type Type of key (ui32|ui64|ptr) |
| 471 | + * @param[in] value Storage for each item |
| 472 | + * @param[in] ht Hash table to iterate over |
| 473 | + * |
| 474 | + * This macro provides a simple way to loop over the items in an opal_hash_table_t. It |
| 475 | + * is not safe to call opal_hash_table_remove* from within the loop. |
| 476 | + * |
| 477 | + * Example Usage: |
| 478 | + * |
| 479 | + * uint64_t key; |
| 480 | + * void * value; |
| 481 | + * OPAL_HASH_TABLE_FOREACH(key, uint64, value, ht) { |
| 482 | + * do_something(key, value); |
| 483 | + * } |
| 484 | + */ |
| 485 | +#define OPAL_HASH_TABLE_FOREACH(key, type, value, ht) \ |
| 486 | + for (void *_nptr=NULL; \ |
| 487 | + OPAL_SUCCESS == opal_hash_table_get_next_key_##type(ht, &key, (void **)&value, _nptr, &_nptr);) |
466 | 488 |
|
467 | 489 | END_C_DECLS
|
468 | 490 |
|
|
0 commit comments