• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Hashtable in a Hashtable

Status
Not open for further replies.
You don't need a hashtable in a hashtable for that. You can simulate multi-dimensional arrays with n-dimension to 1-dimension algorithms.

Assuming a normal hashtable save is [x][y] 2D, you can simulate [x][y][z] 3D by doing [x][y + z*width], where 'width' is the max array size for y. (or rather, the max array # that y can reach plus 1, to avoid collisions) So if you want [0][5][1], where the width of y is 10, then it would end up being [0][5 + 1*10] which is [0][15], a unique index.

For 4D, you can continue the algorithm with [x][y + width * (z + depth * a)]. And so on. You can look up a lot of these algorithms with google.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Yes but this seems impractical seeing as you are only allowed 256 hashtables and game caches and there is no way to destroy them.

Only if you were mapping 2 indices to a hashtable reference would this be used but I do not know of such a situation off the top of my head.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Yes but this seems impractical seeing as you are only allowed 256 hashtables and game caches and there is no way to destroy them.

Only if you were mapping 2 indices to a hashtable reference would this be used but I do not know of such a situation off the top of my head.

Flushing a hashtable destroys it.

SaveHashtableHandle(hashtable, integer, integer, hashtable)


So to answer your question very shortly and simply, you can save hashtables in hashtables.

edit
Also, I know how frustrating it is when people don't answer your question and instead say something like, why, or you can do it another way.
 
Last edited:
Level 16
Joined
Mar 3, 2006
Messages
1,564
Yes but this seems impractical seeing as you are only allowed 256 hashtables and game caches and there is no way to destroy them.

Only if you were mapping 2 indices to a hashtable reference would this be used but I do not know of such a situation off the top of my head.

I guess PurgeAndFire's algorithm doesn't involve using more than 1 hashtable.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Generally you use multiple hashtables in parallel as that can help keep them opperating efficiently. In this case you would purly map references to parallel hashtables in series. If you ran hashtables in series you would quickly hit the 256 hashtable/game cache limit.
 
Level 16
Joined
Aug 7, 2009
Messages
1,403
I guess PurgeAndFire's algorithm doesn't involve using more than 1 hashtable.

Surely not, but saving a hashtable in another one does, and that's what you were willing to do. He responded to the main post, not to PurgeandFire's method.

I'd recommend using PurgeandFire's method, vJASS' struct arrays use the very same method to handle arrays. Keys may go up to 2^32, so you won't really run out of space even if you make a 10D array with a size of 80000 each.
 
Status
Not open for further replies.
Top