From 314f354ee77892664f49b4b44d2052df139ece7e Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Tue, 21 Nov 2017 20:58:48 +0000 Subject: oidmap: add oidmap iterator methods Add the usual map iterator functions to oidmap. Signed-off-by: Jeff Hostetler Reviewed-by: Jonathan Tan Signed-off-by: Junio C Hamano --- oidmap.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'oidmap.h') diff --git a/oidmap.h b/oidmap.h index 18f54cde14..d3cd2bb590 100644 --- a/oidmap.h +++ b/oidmap.h @@ -65,4 +65,26 @@ extern void *oidmap_put(struct oidmap *map, void *entry); */ extern void *oidmap_remove(struct oidmap *map, const struct object_id *key); + +struct oidmap_iter { + struct hashmap_iter h_iter; +}; + +static inline void oidmap_iter_init(struct oidmap *map, struct oidmap_iter *iter) +{ + hashmap_iter_init(&map->map, &iter->h_iter); +} + +static inline void *oidmap_iter_next(struct oidmap_iter *iter) +{ + return hashmap_iter_next(&iter->h_iter); +} + +static inline void *oidmap_iter_first(struct oidmap *map, + struct oidmap_iter *iter) +{ + oidmap_iter_init(map, iter); + return oidmap_iter_next(iter); +} + #endif -- cgit v1.2.3