From 852a21d68ec2850f95b74a829639264ddf264f30 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 8 May 2023 18:43:36 +0100 Subject: [PATCH] [Minor] Add utility to iterate over values by pointer and keys --- contrib/libucl/khash.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/contrib/libucl/khash.h b/contrib/libucl/khash.h index 3e580011d..0b8a4356d 100644 --- a/contrib/libucl/khash.h +++ b/contrib/libucl/khash.h @@ -583,6 +583,14 @@ static kh_inline khint_t __ac_Wang_hash(khint_t key) code; \ } } +#define kh_foreach_key_value_ptr(h, kvar, pvvar, code) { khint_t __i; \ + for (__i = kh_begin(h); __i != kh_end(h); ++__i) { \ + if (!kh_exist(h,__i)) continue; \ + (kvar) = kh_key(h,__i); \ + (pvvar) = &kh_val(h,__i); \ + code; \ + } } + #define kh_foreach_key(h, kvar, code) { \ khint_t __i; \ for (__i = kh_begin(h); __i != kh_end(h); ++__i) { \ -- 2.39.5