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

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 64
Joined
Jan 18, 2005
Messages
27,287
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