View Full Version : Given a node in a collection, fastest way to get index ?

07 July 2011, 08:47 AM
given a builtin collection, like lights, one can access the members of the collection via index:
lights[1] will give you the first light and so on...

Now lets assume i got a light-node Free_Spot:Fspot012
what would be the fastest way to get this node's index in the lights collection ?

I know that one can cycle through the collection via for loop or while, using the above mentioned lights[index] access method, until you find Free_Spot:Fspot012 's entry

now i'm curious, are there any ( faster ) alternatives ?

07 July 2011, 09:34 AM
findItem (lights as array) $Fspot012

07 July 2011, 09:45 AM
ha - thanks a lot Io -
would never have thought that casting to an array would be faster than a loop, but apparently looking in the MXS docs ( MAXScript FAQ > How To Make It Faster > Using Bsearch For Fast Table Lookup ) you are right ...

thanks again :thumbsup:

CGTalk Moderation
07 July 2011, 09:45 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.