Remove not removing..

BlitzMax Forums/BlitzMax Programming/Remove not removing..

Well I was wrong about the loop idea. The list is created in such a way that you can do a for/eachin and remove them all. Your problem is that you forgot to implement a compare method for your type.

I did some fooling with the list and the remove method works if you do:
Strict 

'make a type
Type mytype
	Field value:Int
	
	Method compare(c:Object)
		Return (value-mytype(c).value)
	End Method
End Type

'make a list
Local list:TList=New TList

'initialize the list
Local a:mytype
For Local i:Int=0 To 9
	a=New mytype
	a.value=i
	list.AddFirst(a)
Next

'create an initialize a type to remove
Local b:mytype=New mytype
b.value=5

'remove the type
list.Remove(b)

'check the list for the removed object
For b=EachIn list
	Print b.value
	Print
Next

'remove all the other objects
For b=EachIn list
	list.remove(b)
Next

'check the list again
For b=EachIn list
	Print b.value
	Print
Next


Also just to be picky your loop above wouldn't work because if you delete the first element then the second element will become the first and the third will become the second. You'd end up deleting only every other element.