Based on suggestion from bitbckt: I saw this in my feed, and feel it merits comment. I hope you don't mind the input. You'll want to monitor the load factor of the hash table and re- hash the table on insert when it is exceeded. Otherwise, key lookup will degrade toward linear time for sets of keys with a high number of collisions. The easiest way to implement the load factor is to maintain a count of allocated nodes in tvm_htab_t and divide that by the bucket count to obtain the load factor. Of course, you'd need the bucket count (HTAB_SIZE) to be dynamic, too. |
||
|---|---|---|
| .. | ||
| .gitignore | ||
| tvm.c | ||
| tvm_file.c | ||
| tvm_hashtab.c | ||
| tvm_lexer.c | ||
| tvm_memory.c | ||
| tvm_program.c | ||
| tvm_stack.c | ||