• 🏆 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 key maximum size?

Status
Not open for further replies.
Level 4
Joined
Jan 27, 2016
Messages
89
Is there a maximum size to a hashtables key and if so, how much?

Whats stopping me from just converting the following strings to integers and using them

[(UnitID1)][(UnitID2).2]
[(UnitID1)][(UnitID2).3]

Basically using periods to seperate pieces of input data into the hashtable and having multiples of them, sort of simulating multidimensional arrays? Realistic Example of a hashtable that saves a lot of units to its number that fit certain criteria,
[Number][Criteria1.Criteria2.Criteria3]
where in this case, criteria 1 is, is the unit flying, 2 is is it undead, 3 is its level above 3
save number of those units into 0
and then loop from 0 to whatever the number above is for all those units
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
Sounds like a waste.
There are too many alternatives for multidimensional arrays to be truly useful, at least in wc3 modding.

At times, I'd prefer a 2D array-like syntax which translates to hashtables on compilation. But that's about it, otherwise I would not see much use in it.
I think vjass has support for 2d arrays, by the way.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Is there a maximum size to a hashtables key and if so, how much?
Maximum -> 2,147,483,647
Minimum -> -2,147,483,648
Whats stopping me from just converting the following strings to integers and using them

[(UnitID1)][(UnitID2).2]
[(UnitID1)][(UnitID2).3]
Neither of those strings contain reasonably resolved integers. As such some internal error will occur and likely 0 will be returned.
Basically using periods to seperate pieces of input data into the hashtable and having multiples of them, sort of simulating multidimensional arrays? Realistic Example of a hashtable that saves a lot of units to its number that fit certain criteria,
Hash tables take integers and not strings.

If you are referring to taking a hash of a string using the hash native then you run the risk of hash collisions occurring. Let us not forget that all unique strings leak as there is no garbage collection for strings.
 
Status
Not open for further replies.
Top