X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=dict.h;h=ab962c20469bfae94808dbc8e2271a169edfd3b1;hb=c11f1953e31a1baa1d6785757169c7fd35cdc51d;hp=af21015650d906b7e7e9e0c2de6f86c6f4329d7c;hpb=352e7bb836a852c4df6810e6be58990f602cf7a1;p=wordgame diff --git a/dict.h b/dict.h index af21015..ab962c2 100644 --- a/dict.h +++ b/dict.h @@ -82,6 +82,9 @@ dict_count (dict_t *dict, int dict_print (dict_t *dict); +int +dict_print_by_length (dict_t *dict); + int dict_print_if (dict_t *dict, dict_entry_predicate_t predicate); @@ -90,6 +93,31 @@ int dict_print_by_length_if (dict_t *dict, dict_entry_predicate_t predicate); +/* More general callback-based iteration of all entries */ +typedef void (* dict_action_t) (void *closure, char *word, dict_entry_t *entry); + +int +dict_for_each (dict_t *dict, + dict_action_t action, + void *closure); + +int +dict_for_each_by_length (dict_t *dict, + dict_action_t action, + void *closure); + +int +dict_for_each_if (dict_t *dict, + dict_action_t action, + void *closure, + dict_entry_predicate_t predicate); + +int +dict_for_each_by_length_if (dict_t *dict, + dict_action_t action, + void *closure, + dict_entry_predicate_t predicate); + /* Character-by-character perusal of the dictionary */ dict_cursor_t dict_root (dict_t *dict);