• 🏆 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!

[Solved] How to check whether HashTable is empty?

Level 6
Joined
Sep 10, 2022
Messages
86
Hello, currently I am studying hashtables, and I have following:
  • Hashtable - Save Handle Of(Picked unit) as (Key (Picked unit)) of 0 in townhalls_hash
I store some units, then there may be a situation when I remove them from the hashtable. How can I check whether Hashtable is empty?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,570
Do you mean you want to check if a specific Parent + Child key value is empty? You have these functions which I believe are only available in Jass:
vJASS:
HaveSavedValue(key, valueType, missionKey, table)
HaveSavedHandle(table, parentKey, childKey)
HaveSavedInteger(table, parentKey, childKey)
HaveSavedReal(table, parentKey, childKey)
HaveSavedBoolean(table, parentKey, childKey)
HaveSavedString(table, parentKey, childKey)
Otherwise, you can use an Integer variable to track the number of entries or save the amount of entries directly into the Hashtable. So whenever you Save something you can increase the integer by 1 and whenever you remove something decrease the integer by 1. Then you can check the value of the integer to determine if it's empty or not (0 = empty).
 
Level 6
Joined
Sep 10, 2022
Messages
86
Do you mean you want to check if a specific Parent + Child key value is empty? You have these functions which I believe are only available in Jass:
vJASS:
HaveSavedValue(key, valueType, missionKey, table)
HaveSavedHandle(table, parentKey, childKey)
HaveSavedInteger(table, parentKey, childKey)
HaveSavedReal(table, parentKey, childKey)
HaveSavedBoolean(table, parentKey, childKey)
HaveSavedString(table, parentKey, childKey)
Otherwise, you can use an Integer variable to track the number of entries or save the amount of entries directly into the Hashtable. So whenever you Save something you can increase the integer by 1 and whenever you remove something decrease the integer by 1. Then you can check the value of the integer to determine if it's empty or not (0 = empty).

Actually, I thought about that, I asked just in case, if there was a function that I might have missed. Probably I'll use the second option. Thank you.
 
Top