• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Loop Question

Status
Not open for further replies.
Level 11
Joined
Jun 30, 2008
Messages
580
I am making a system that I believe will be using around 5 to 6 loops. Is this a problem? Is there an alternative to using loops that are more efficient.

Basically there will be methods for users to use to add a certain thing to the info with the struct:

call name.AddUnit(XunitX)
call name.AddUnit(XunitX2)

etc.

And the only way I can think of in the system that uses this info, is in the method have:
JASS:
method AddUnit takes unit u returns nothing
     set .array = .array+1
     set .unit[array] = u
endmethod

and in the system it will run through .array to find the right .unit.

and I will have several of these, is there any other alternative or does it not matter?
 
It shouldn't matter, as long as you are not hitting the op limit. Multiple loops are usually fine, depending on whatever is within the loops. :)

If you are performing several thousands of functions, then just beware of the op limit. However, there are workarounds to that, such as by using ExecuteFunc() or triggers to start a new thread.

In terms of efficiency, it really depends on the code on whether or not there is an alternative.
 
Status
Not open for further replies.
Back
Top