I've been using klib's khash for my own project, and I've written some convenience functions. I was wondering if there might be interest in incorporating them into the core implementation:
kh_getval(name, h, key, defval): Return the value corresponding to key key, or defval if the key is not found.
kh_set(name, h, key, val): Set the value corresponding to key key to val, inserting into table if key is absent and overwriting if present.
kh_unset(name, h, key): A more user-friendly kh_del(): checks if key is in the table, and deletes if it is.
I would be happy to submit a pull request incorporating these.
I've been using
klib
'skhash
for my own project, and I've written some convenience functions. I was wondering if there might be interest in incorporating them into the core implementation:kh_getval(name, h, key, defval)
: Return the value corresponding to keykey
, ordefval
if the key is not found.kh_set(name, h, key, val)
: Set the value corresponding to keykey
toval
, inserting into table ifkey
is absent and overwriting if present.kh_unset(name, h, key)
: A more user-friendlykh_del()
: checks ifkey
is in the table, and deletes if it is.I would be happy to submit a pull request incorporating these.