|
pforth
0943e5e71114f286dbb2474d55aabf91df02d104
|
Functions | |
| dict_t * | dict_create (uint32_t size) |
| void | dict_free (dict_t *dict, uint32_t size) |
| int | hash (dict_t *hashtable, const char *key) |
| dict_entry * | dict_newkv (const char *key, const pforth_word_ptr value) |
| pforth_word_ptr | dict_set (dict_t *dict, const char *key, const pforth_word_ptr value) |
| pforth_word_ptr | dict_get (dict_t *dict, const char *key) |
| dict_t* dict_create | ( | uint32_t | size | ) |
Create a new hash table dictionary.
| size | number of elements |
| void dict_free | ( | dict_t * | dict, |
| uint32_t | size | ||
| ) |
| pforth_word_ptr dict_get | ( | dict_t * | dict, |
| const char * | key | ||
| ) |
Retrieve the word from the dictionary.
| dict | dictionary to use |
| key | FORTH word in ASCII form |
| dict_entry* dict_newkv | ( | const char * | key, |
| const pforth_word_ptr | value | ||
| ) |
Create a key-value pair for dictionary.
Internal function to be used only inside dictionary.
| key | the FORTH word in ASCII |
| value | pointer to the actual pforth_word structure |
| pforth_word_ptr dict_set | ( | dict_t * | dict, |
| const char * | key, | ||
| const pforth_word_ptr | value | ||
| ) |
Insert word into dictionary.
The word will be copied into the dictionary. The value must be freed in caller afterwards.
| dict | dictionary to use |
| key | FORTH word in ASCII form |
| value | pointer to pforth_word struct with the word. |
| int hash | ( | dict_t * | hashtable, |
| const char * | key | ||
| ) |
djb2 hash function
Hope it'll be more or less unique to create hash table for FORTH words
| hashtable | pointer to hash table |
| key | null-terminated key string |