aboutsummaryrefslogtreecommitdiff
path: root/src/string_map.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-12-09 11:29:28 +0000
committergingerBill <bill@gingerbill.org>2022-12-09 11:29:28 +0000
commit34a048f7daaf93b16ae4121bf5238f9008f3465b (patch)
tree3857fdc80f73522a8b2af265f257a4decd447afd /src/string_map.cpp
parentffe953b43d1ad31d2c37f544a1d389e30d8f69bf (diff)
Replace compiler for loops for the hash-table types to simplify code usage
Diffstat (limited to 'src/string_map.cpp')
-rw-r--r--src/string_map.cpp23
1 files changed, 23 insertions, 0 deletions
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 <typename T>
struct StringMap {
+ using K = String;
+ using V = T;
Slice<MapIndex> hashes;
Array<StringMapEntry<T> > entries;
};
@@ -270,3 +272,24 @@ gb_inline void string_map_clear(StringMap<T> *h) {
}
}
+
+
+template <typename T>
+StringMapEntry<T> *begin(StringMap<T> &m) {
+ return m.entries.data;
+}
+template <typename T>
+StringMapEntry<T> const *begin(StringMap<T> const &m) {
+ return m.entries.data;
+}
+
+
+template <typename T>
+StringMapEntry<T> *end(StringMap<T> &m) {
+ return m.entries.data + m.entries.count;
+}
+
+template <typename T>
+StringMapEntry<T> const *end(StringMap<T> const &m) {
+ return m.entries.data + m.entries.count;
+} \ No newline at end of file