News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

my hashtable library

Started by diablo2oo2, March 14, 2012, 12:31:30 AM

Previous topic - Next topic

diablo2oo2

i coded an own hashtable library for managing complex data structures in an easy way.

features:
-it will organize memory itself (will use the windows Heap functions)
-like in java you can access items via a key which can be a String or an integer
-support for nested hashtables (so you can create very easy complex data trees)
-save/load the hashtable to disk or memory (with nested hashtables)

to do:
-sort function
-testting, bug fixing?



the example will show how to create following hashtable structure:

; ht_1
;   |
;   +-0-->"hello 1"
;   +-1-->"hello 2"
;   +-2-->"hello 3"
;   +-"string key"-->"hello 4"
;   |
;   +-"ht_2"-->ht_2
;                      |
;                      +-0-->"i am in the second hashtable"
;                      +-123->binary_data

Tedd

Had a quick look - seems okay, and is obviously useful, but I have a few comments :wink

- This isn't a hashtable, it's more of an indexable list with hash IDs. You're hashing each item to serve as a unique identifier, whereas a hashtable uses the hash to lookup the item directly (no searching the list.)
- MD5 seems like overkill - both in terms of time and memory cost - when a much simpler 32-bit hash would do just as well.
- You're not handling collisions. Even with MD5, while unlikely with smaller items, it's still possible for two different items to have the same hash value.
No snowflake in an avalanche feels responsible.