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
 
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.
 
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.
Back
Top