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

[vJASS] Loop through all instances of a struct

Status
Not open for further replies.
Level 17
Joined
Mar 21, 2011
Messages
1,597
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 39
Joined
Feb 27, 2007
Messages
5,024
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