diff --git a/include/picrin/dict.h b/include/picrin/dict.h index ae118e13..8bc58ad8 100644 --- a/include/picrin/dict.h +++ b/include/picrin/dict.h @@ -23,6 +23,7 @@ pic_value pic_dict_ref(pic_state *, struct pic_dict *, pic_sym); void pic_dict_set(pic_state *, struct pic_dict *, pic_sym, pic_value); void pic_dict_del(pic_state *, struct pic_dict *, pic_sym); size_t pic_dict_size(pic_state *, struct pic_dict *); +bool pic_dict_has(pic_state *, struct pic_dict *, pic_sym); #if defined(__cplusplus) } diff --git a/src/dict.c b/src/dict.c index e9fd5e80..d3eb895b 100644 --- a/src/dict.c +++ b/src/dict.c @@ -44,6 +44,14 @@ pic_dict_size(pic_state *pic, struct pic_dict *dict) return dict->hash.count; } +bool +pic_dict_has(pic_state *pic, struct pic_dict *dict, pic_sym key) +{ + UNUSED(pic); + + return xh_get_int(&dict->hash, key) != NULL; +} + void pic_dict_del(pic_state *pic, struct pic_dict *dict, pic_sym key) {