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

[JASS] IsUnitInGroup Question

Status
Not open for further replies.
Just wondering if anyone knows how efficient IsUnitInGroup native is. Does the efficiency of it drop as more units are added to the group? In that case, would a boolean array read (with an UnitIndexer of course) be more efficient in terms of determining if a certain unit is in a group?

I don't really think it is worth it unless you have a really large number of units in the group (I'm assuming what Griffen said is true).

You can achieve O(1) with a unit indexer + boolean read (1 boolean array per group), but it is extra work trying to manage it (set it to true when you add a unit or enum a unit, set it to false when you remove a unit). It is especially annoying if you are using GroupClear() because then you have to iterate through the entire list and set them to false.

The other issue with it is that you can't arbitrarily input a group like you can with IsUnitInGroup(). You would have to know which group in particular you are referencing, and then read its particular boolean array. Another option would be to create a list of groups per unit, but again that is even more management. :p
 
Status
Not open for further replies.
Top