Hashtable help

Status
Not open for further replies.
Level 4
Joined
Sep 14, 2011
Messages
47
Hey guys:

I am hoping to get some advice about data structures and retrieval using hashtables, which I think are so much cooler than arrays.

I have a creep unit each guarding a tower, whose handle I have saved under the key of a specific tower, as such:

Hashtable - Save Handle of CreepUnit as (key guard) of (Key TowerUnit)

So now I can easily retrieve the handle of the Creep Unit using the handle of the Tower. But when the CreepUnit dies, is there any easy way to retrieve the handle of the parent tower unit (ie in reverse?). Is it possible to store the information so it would work in two ways or is arrays the only option really?

Thanks!
 
Just save both ways:
Hashtable - Save Handle of CreepUnit as (..) of (Key TowerUnit)
Hashtable - Save Handle of TowerUnit as (..) of (Key CreepUnit)

Keep in mind that you need to ensure consistency. So for example if the creep dies and you create a new creep you have to change BOTH hashtable entries.
 
Status
Not open for further replies.
Back
Top