Question about lists

Monkey Forums/Monkey Programming/Question about lists

Armoured(Posted 2012) [#1]
Hi,
How I can delete a single (not the first or the last) item inside a list?


Thanks


NoOdle(Posted 2012) [#2]
Two options, the first is to remove each:

[monkeycode]
myList.RemoveEach( item )
[/monkeycode]

the other option, which is faster is to store the node when you add the item to the list and then you can remove the node like this (removing the item from the list):

[monkeycode]
'stores node
field lnk : list.Node< Type >

'add item and store node
lnk = myList.AddFirst( item )

'removes item
lnk.Remove()
[/monkeycode]


teremochek(Posted 2012) [#3]
I use it.
For Local g:Item = Eachin ItemList
 If Item(g) Then ItemList.RemoveEach(g) 
Next