[Solved] How to check whether HashTable is empty?

Status
Not open for further replies.
Level 7
Joined
Sep 10, 2022
Messages
101
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 73
Joined
Aug 10, 2018
Messages
7,866
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 7
Joined
Sep 10, 2022
Messages
101
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.
 
Status
Not open for further replies.
Top