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

Remove All Units of Group From Group Efficiency.

Status
Not open for further replies.
Level 11
Joined
Aug 6, 2009
Messages
697
Presumably it's more efficient than FirstOfGroup or ForGroup -based removal loops.
Okay but that still has an N run-time I'm assuming.

BlzGroupRemoveGroupFast might be O(1), going by the presumption that adding a group quickly just appends the entire target list (group) to the desired list of units (whichGroup)

The function above might be O(N), based on how it was implemented before.

BlzGroupRemoveFast is 1.31 isn't it?
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,190
If you want to clear a group then use the appropriate native to do so...
JASS:
native GroupClear takes group whichGroup returns nothing
If you want to remove all units in group B from group A then this is the current implementation...
JASS:
function GroupRemoveGroup takes group sourceGroup,group destGroup returns nothing
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false
    set bj_groupRemoveGroupDest = destGroup
    call ForGroup(sourceGroup, function GroupRemoveGroupEnum)
    if (wantDestroy) then
        call DestroyGroup(sourceGroup)
    endif
endfunction

function GroupRemoveGroupEnum takes nothing returns nothing
    call GroupRemoveUnit(bj_groupRemoveGroupDest, GetEnumUnit())
endfunction
On the 1.31 PTR there is this native implementation, which is likely considerably faster...
JASS:
native BlzGroupRemoveGroupFast takes group whichGroup,group removeGroup returns integer
 
Status
Not open for further replies.
Top