• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

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 41
Joined
Jun 9, 2011
Messages
13,248
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 65
Joined
Jan 18, 2005
Messages
27,296
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