TLists
BlitzMax Forums/BlitzMax Programming/TLists
| ||
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. |
| ||
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) |
| ||
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. |
| ||
I think it should be:Method Destroy() object_list.Remove(Self) If object_list.contains(Self) Then Notify "Gah" End Method --Byteemoz |
| ||
Gah is still notified with that, how exactly does 'contains' work? |
| ||
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 |