oidmap: add oidmap iterator methods

Add the usual map iterator functions to oidmap. Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Reviewed-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff Hostetler committed Nov 21, 2017 at 20:58 UTC 314f354ee77892664f49b4b44d2052df139ece7e
1 file changed +22
oidmap.h
+22
@@ -65,4 +65,26 @@ extern void *oidmap_put(struct oidmap *map, void *entry);
65 */
66 extern void *oidmap_remove(struct oidmap *map, const struct object_id *key);
67
68 +
69 +struct oidmap_iter {
70 + struct hashmap_iter h_iter;
71 +};
72 +
73 +static inline void oidmap_iter_init(struct oidmap *map, struct oidmap_iter *iter)
74 +{
75 + hashmap_iter_init(&map->map, &iter->h_iter);
76 +}
77 +
78 +static inline void *oidmap_iter_next(struct oidmap_iter *iter)
79 +{
80 + return hashmap_iter_next(&iter->h_iter);
81 +}
82 +
83 +static inline void *oidmap_iter_first(struct oidmap *map,
84 + struct oidmap_iter *iter)
85 +{
86 + oidmap_iter_init(map, iter);
87 + return oidmap_iter_next(iter);
88 +}
89 +
90 #endif