summaryrefslogtreecommitdiff
path: root/oidmap.h
diff options
context:
space:
mode:
authorJeff Hostetler <jeffhost@microsoft.com>2017-11-21 20:58:48 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-11-22 05:11:56 (GMT)
commit314f354ee77892664f49b4b44d2052df139ece7e (patch)
treee47af121f8d64129d583a0c50b8324d7f45b7c24 /oidmap.h
parent578d81d0c445f714dce46d5f4e3f599ac3a94c75 (diff)
downloadgit-314f354ee77892664f49b4b44d2052df139ece7e.zip
git-314f354ee77892664f49b4b44d2052df139ece7e.tar.gz
git-314f354ee77892664f49b4b44d2052df139ece7e.tar.bz2
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>
Diffstat (limited to 'oidmap.h')
-rw-r--r--oidmap.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/oidmap.h b/oidmap.h
index 18f54cd..d3cd2bb 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