• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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