Skip to content

Commit 314f354

Browse files
jeffhostetlergitster
authored andcommitted
oidmap: add oidmap iterator methods
Add the usual map iterator functions to oidmap. Signed-off-by: Jeff Hostetler <[email protected]> Reviewed-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 578d81d commit 314f354

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

oidmap.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,26 @@ extern void *oidmap_put(struct oidmap *map, void *entry);
6565
*/
6666
extern void *oidmap_remove(struct oidmap *map, const struct object_id *key);
6767

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+
6890
#endif

0 commit comments

Comments
 (0)