Remove not removing..

BlitzMax Forums/BlitzMax Programming/Remove not removing..

First the compare method is called by these functions: sort, contains, findlink and remove calls FindLink and therefore indirectly calls compare.

Depending on how you're using the list implmenting a compare method may or may not be useful. If you don't implement one the parent's compare method will be called.

Object.Compare returns the difference in memory addresses of the 2 objects so even objects identical in values will not be found equal.

If you want to remove every object in a list just do
list.Clear().

If you want to remove an object based on some value just implement a compare for the type and wrap the value in the type and call the list.remove() method.
-or-
Without the compare method do this.
for a:mytype = eachin mylist
    if a.value=specificValue then mylist.remove(a)
next

That can be very wasteful if the list is long because you have to find the object to call remove on it, but remove has to go find the object again before it can be removed.