- Joined
- Nov 21, 2012
- Messages
- 835
Regarding vJass Optimization: Using a First of Group Loop for Enumeration tutorial, I'm not sure I understand swaping group method
This is a example script from above tutorial
I'm embarrassed with group "temp". Is this needed? Would not be enough to do after endloop:
This is a example script from above tutorial
JASS:
scope test
globals
private group iterator=CreateGroup()
private group swap=CreateGroup()
private group temp
endglobals
private function fgSwap takes nothing returns nothing
local unit FoG
loop
set FoG=FirstOfGroup(iterator)
exitwhen FoG==null
//
call GroupAddUnit(swap,FoG)
call GroupRemoveUnit(iterator,FoG)
endloop
set temp=iterator
set iterator=swap
set swap=temp
endfunction
endscope
I'm embarrassed with group "temp". Is this needed? Would not be enough to do after endloop:
JASS:
// set temp=iterator //"iterator" is empty, what for we set "temp" as empty group?
set iterator=swap
// set swap=temp // can't we just call GroupClear(swap) ?