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

[vJASS] Loop through all instances of a struct

Status
Not open for further replies.
Level 17
Joined
Mar 21, 2011
Messages
1,611
Hey guys,

is there a built in way to loop through all instances of a struct?
I usually write my own allocate/deallocate with a double linked list, so i can just go through the instances.
But in certain cases, i want pre-build structs (non array), so i wonder if there is a default way to do so?

thanks!
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
No. In many cases all 'currently in use' instances are sequential but that isn't guaranteed. Best you could do would be to implement a boolean member that gets set = true/false on allocate/deallocate, then loop over them all manually from 0 to 32767 while checking that member. Stop the loop early if (for example) you find N or more inactive instances sequentially.
 
Last edited:
Status
Not open for further replies.
Top