• 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.

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!
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
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.
Top