diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-09-07 21:39:15 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-09-08 05:55:44 +0200 |
commit | 7bf9e0d5f67f927ce3e250812e219536aff2b448 (patch) | |
tree | 4ce6787bd0306cc9c5f1f693600baca8cbbb2da1 /src/basic/hashmap.h | |
parent | ci: temporarily disable Packit's i386 (diff) | |
download | systemd-7bf9e0d5f67f927ce3e250812e219536aff2b448.tar.xz systemd-7bf9e0d5f67f927ce3e250812e219536aff2b448.zip |
hashmap: introduce HASHMAP_BASE_FOREACH() and friend
Diffstat (limited to '')
-rw-r--r-- | src/basic/hashmap.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/basic/hashmap.h b/src/basic/hashmap.h index ad85093d69..233f1d7a1e 100644 --- a/src/basic/hashmap.h +++ b/src/basic/hashmap.h @@ -415,6 +415,11 @@ static inline int set_dump_sorted(Set *h, void ***ret, size_t *ret_n) { * the entries were inserted. * It is safe to remove the current entry. */ +#define _HASHMAP_BASE_FOREACH(e, h, i) \ + for (Iterator i = ITERATOR_FIRST; _hashmap_iterate((h), &i, (void**)&(e), NULL); ) +#define HASHMAP_BASE_FOREACH(e, h) \ + _HASHMAP_BASE_FOREACH(e, h, UNIQ_T(i, UNIQ)) + #define _HASHMAP_FOREACH(e, h, i) \ for (Iterator i = ITERATOR_FIRST; hashmap_iterate((h), &i, (void**)&(e), NULL); ) #define HASHMAP_FOREACH(e, h) \ @@ -425,6 +430,11 @@ static inline int set_dump_sorted(Set *h, void ***ret, size_t *ret_n) { #define ORDERED_HASHMAP_FOREACH(e, h) \ _ORDERED_HASHMAP_FOREACH(e, h, UNIQ_T(i, UNIQ)) +#define _HASHMAP_BASE_FOREACH_KEY(e, k, h, i) \ + for (Iterator i = ITERATOR_FIRST; _hashmap_iterate((h), &i, (void**)&(e), (const void**) &(k)); ) +#define HASHMAP_BASE_FOREACH_KEY(e, k, h) \ + _HASHMAP_BASE_FOREACH_KEY(e, k, h, UNIQ_T(i, UNIQ)) + #define _HASHMAP_FOREACH_KEY(e, k, h, i) \ for (Iterator i = ITERATOR_FIRST; hashmap_iterate((h), &i, (void**)&(e), (const void**) &(k)); ) #define HASHMAP_FOREACH_KEY(e, k, h) \ |