hashtable - Hash tables: Whats the best way to mark a bucket empty? -
ran annoying problem - need way tell if bucket i'm trying fill empty or not (the buckets stored array of value type structs key-value pairs).
if reserve key value marking things empty mean data unfortunate enough stumble on hash value never accessible. on other hand, including boolean in kvp struct increase size of struct 16 24, (such waste , i'm tight on memory is). has figured out solution this?
this problem intrinsic hash tables collisions. related problem dealing deleting hash table, again, in context of collisions. there's no solution doesn't involve compromise in performance, it's pretty common see hash table implementations have particular key illegal.
by far direct solution special-case key value you're using mean empty. is, if user trying store key value 0, put in special array keep around purpose.
really lame hash tables work pointers don't have issue, since can find pointer value caller can't pass in (such pointer object own). hash tables using linked lists or array elements don't have problem either, then, there's massive performance penalty those.
you find clever way encode inside table itself, using multiple elements. way better if somehow unified deleted element handling or else, free or faster checking separate list.
Comments
Post a Comment