The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: diablo2oo2 on March 14, 2012, 12:31:30 AM

Title: my hashtable library
Post by: diablo2oo2 on March 14, 2012, 12:31:30 AM
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
Title: Re: my hashtable library
Post by: Tedd on March 14, 2012, 05:37:28 PM
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.