From 34a048f7daaf93b16ae4121bf5238f9008f3465b Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 9 Dec 2022 11:29:28 +0000 Subject: Replace compiler for loops for the hash-table types to simplify code usage --- src/string_map.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/string_map.cpp') diff --git a/src/string_map.cpp b/src/string_map.cpp index 218a45482..e2a4d5f65 100644 --- a/src/string_map.cpp +++ b/src/string_map.cpp @@ -30,6 +30,8 @@ struct StringMapEntry { template struct StringMap { + using K = String; + using V = T; Slice hashes; Array > entries; }; @@ -270,3 +272,24 @@ gb_inline void string_map_clear(StringMap *h) { } } + + +template +StringMapEntry *begin(StringMap &m) { + return m.entries.data; +} +template +StringMapEntry const *begin(StringMap const &m) { + return m.entries.data; +} + + +template +StringMapEntry *end(StringMap &m) { + return m.entries.data + m.entries.count; +} + +template +StringMapEntry const *end(StringMap const &m) { + return m.entries.data + m.entries.count; +} \ No newline at end of file -- cgit v1.2.3