TLists

BlitzMax Forums/BlitzMax Programming/TLists

Ragz(Posted 2006) [#1]
I have a TList of objects which is looped over to draw them, but I wasn't sure how to remove an item, at first I was using the_list.remove self (as a method), but I had to settle with getting the link, and then removing that. But if I use the_list.contains(the_object), it returns true, but I know the the loop of the list didn't get it, what's going on?

Perhaps I simple don't understand what these commands do.


Dreamora(Posted 2006) [#2]
Without a code showing what you did, it sounds like you forgot some points of your code as the described thing should work. (assumed that self is the same object as the_object) (you could use self there as well)


Ragz(Posted 2006) [#3]
Ok, sorry about the lack of information:

Function update_all()	
	Local a:TObject
	
	For a = EachIn object_list		
		a.update()
			
	Next
	
End Function

Method Destroy()			
	object_index[self.index].link.remove

	If object_list.contains(Self) Then Notify "Gah"
				
End Method


"Gah" always shows, yet the removed objects are never looped through again.


Byteemoz(Posted 2006) [#4]
I think it should be:
Method Destroy()			
	object_list.Remove(Self)
	If object_list.contains(Self) Then Notify "Gah"
End Method

--Byteemoz


Ragz(Posted 2006) [#5]
Gah is still notified with that, how exactly does 'contains' work?


Byteemoz(Posted 2006) [#6]
Have you been fiddeling around with the internal structures of the linked list? Because that works:

'Contains(val:Object)' traverses all TLinks within the linked list and returns True when the value of one of them matches 'val'.

-- Byteemoz