diff options
author | Andrea Canciani <ranma42@gmail.com> | 2013-06-17 15:19:26 +0200 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2013-06-17 15:19:26 +0200 |
commit | 37ed6c33ee0eab580e975e94fdd75d3125b4adf5 (patch) | |
tree | 0bb72865dcef77c7e689331e7b692b1655894c05 | |
parent | 17fe53d1056c1651c8849ebd969c4e40b72a7418 (diff) |
The foreach function iterates over all of the elements and calls a
function which is guaranteed to make no modification to the table,
hence the whole loop never changes the hashtable.
This makes it possible to nest two loops over the same hashtable
without manual casting.
-rw-r--r-- | hashtable.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/hashtable.h b/hashtable.h index 8a4bedb..4aca6b0 100644 --- a/hashtable.h +++ b/hashtable.h @@ -106,7 +106,7 @@ _simpledata_hashtable_size (size_t count, int shift) visibility void prefix##_clear (prefix##_t *hashtable); \ visibility value_t prefix##_get (prefix##_t *hashtable, key_t key); \ visibility void \ - prefix##_foreach (prefix##_t *hashtable, \ + prefix##_foreach (const prefix##_t *hashtable, \ void (*f) (const prefix##_t *hashtable, \ value_t data, void *arg), \ void *arg); \ @@ -322,7 +322,7 @@ _simpledata_hashtable_size (size_t count, int shift) } \ \ visibility void \ - prefix##_foreach (prefix##_t *hashtable, \ + prefix##_foreach (const prefix##_t *hashtable, \ void (*f) (const prefix##_t *hashtable, \ value_t data, void *arg), \ void *arg) \ |