pmix3x: add the PMIX_HASH_TABLE_FOREACH macro
this is a convenience macro similar to the PMIX_LIST_FOREACH macro, that can be used to iterate on all the key/value pairs of a pmix_hash_table_t (back-ported from upstream commit pmix/master@349971c68c)
Этот коммит содержится в:
родитель
73298ad4e2
Коммит
f1dc033767
@ -10,7 +10,7 @@
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2015-2016 Intel, Inc. All rights reserved.
|
||||
* Copyright (c) 2015 Research Organization for Information Science
|
||||
* Copyright (c) 2015-2016 Research Organization for Information Science
|
||||
* and Technology (RIST). All rights reserved.
|
||||
* Copyright (c) 2016 Mellanox Technologies, Inc.
|
||||
* All rights reserved.
|
||||
@ -371,6 +371,29 @@ static inline int pmix_next_poweroftwo(int value)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loop over a hash table.
|
||||
*
|
||||
* @param[in] key Key for each item
|
||||
* @param[in] type Type of key (ui32|ui64|ptr)
|
||||
* @param[in] value Storage for each item
|
||||
* @param[in] ht Hash table to iterate over
|
||||
*
|
||||
* This macro provides a simple way to loop over the items in a pmix_hash_table_t. It
|
||||
* is not safe to call pmix_hash_table_remove* from within the loop.
|
||||
*
|
||||
* Example Usage:
|
||||
*
|
||||
* uint64_t key;
|
||||
* void * value;
|
||||
* PMIX_HASH_TABLE_FOREACH(key, uint64, value, ht) {
|
||||
* do_something(key, value);
|
||||
* }
|
||||
*/
|
||||
#define PMIX_HASH_TABLE_FOREACH(key, type, value, ht) \
|
||||
for (void *_nptr=NULL; \
|
||||
PMIX_SUCCESS == pmix_hash_table_get_next_key_##type(ht, &key, (void **)&value, _nptr, &_nptr);)
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /* PMIX_HASH_TABLE_H */
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user