Monkey and List Nodes

Community Forums/Monkey Talk/Monkey and List Nodes

Space_guy(Posted 2011) [#1]
Can anyone give me an example how to use the list nodes?
I would like to remove a specific object from my list but there is no command top do that except using nodes. But when i try to use them monkey complains that the word Node is a duplicate in both the list module and the map module.
It doesnt matter if I use strict mode or not.

I use the demo version if thats important v.30


therevills(Posted 2011) [#2]
I normally remove objects from a list like this:


Class Bullet
  Global list:List = new List<Bullet>
  Field x#, y#
....

For local b:Bullet = EachIn Bullet.list
  If b.y < 0 Then
    Bullet.list.Remove(b)
  End if
Next




Yasha(Posted 2011) [#3]
Be aware that the (List) Remove method iterates through the entire list, looking for matching values to remove (so the code in post #2 has time O(n^2) ). It's the simplest way but isn't appropriate for performance.

Last edited 2011


degac(Posted 2011) [#4]



Space_guy(Posted 2011) [#5]
Thanks alot degac :) Works perfectly

Last edited 2011