mirror of
https://github.com/lifegpc/c-utils.git
synced 2026-06-06 05:08:45 +08:00
Update
This commit is contained in:
12
dict.h
12
dict.h
@@ -54,6 +54,18 @@ void dict_iter(struct Dict<K, V>* d, void(*callback)(K key, V value, Args... arg
|
||||
callback(t->d.key, t->d.value, args...);
|
||||
}
|
||||
}
|
||||
template <typename K, typename V, typename ... Args>
|
||||
void dict_iter(struct Dict<K, V>* d, void(*callback)(size_t index, K key, V value, Args... args), Args... args) {
|
||||
if (!d || !callback) return;
|
||||
struct Dict<K, V>* t = d;
|
||||
size_t i = 0;
|
||||
callback(i, t->d.key, t->d.value, args...);
|
||||
while (t->next) {
|
||||
t = t->next;
|
||||
i++;
|
||||
callback(i, t->d.key, t->d.value, args...);
|
||||
}
|
||||
}
|
||||
template <typename K, typename V>
|
||||
bool dict_set(struct Dict<K, V>*& d, K key, V value, void(*free_func)(V) = nullptr) {
|
||||
if (!d) {
|
||||
|
||||
Reference in New Issue
Block a user