Hash table functionsFast lookup

Xiqual 0.9.1

Hash table functionsFast lookup


o hash_new
Create a fixed-size hash table.
o hash_free
Free a hash table.
o hash_newnode
Creates a new node with specified name and data.
o hash_freenode
Deallocate a node.
o hash_addnode
Ignorantly add a node to a hash table.
o hash_add
Create node with specified data and add to a hash table.
o hash_find
Look up a node in a hash table.
Fast string lookup.

When you have many (tens of thousands or millions) of uniquely named entries, hash tables are good. In the optimal case, every string lookup takes the same amount of (minimal) time. For hash tables to be any good, every entry should have a different name to be sorted by. The current implementation only allows entries to have strings as base for their key.

When you create a table with hash_new(), you supply a number of tags (keyword and data pairs) which define the number of entries you expect to top out at.

If your table reaches this hard limit, the regular node adding function, hash_add(), refuses to add anymore nodes. You can circumvent this by using the ignorant function hash_add() at the cost of performance, or you could allocate a bigger table and start shuffling the old data over to this.



This page was generated with the help of DOC++.