Tlist Compare, Sort, and Contains, or Why God Why

BlitzMax Forums/BlitzMax Programming/Tlist Compare, Sort, and Contains, or Why God Why

If compare returns 0 for _order = other._order, remove will remove the first with the same order as the searched object, no mather if it is the one you wanted to remove. Same goes for contains.


Sswift: Compare which returns 0 means they are "the same". This means if you look for them through contains / remove, they will be removed, no mather if they are the same as they are "object compare equal" (the only real equalness test on objects). Thats why I restricted 0 to reference qualness. You did not comment in that _Order is a unique value which can't be shared by 2 objects, in which case the return on _order - _order would break with .Remove/.Contains.

My compare was especially targeted for general usage, where no "reference to TLink" is used.


So in general: My compare works, yours will fail. But in the special circumstances you use yours with the TLink backsave, yours will work as long as you do not use TList.Remove / TList.Contains (perhaps others) as those will fail.
You cut of some functionality for speed gains. (I would better add a comment on that, to prevent untrackable bugs later)
I only added my method as the talk was on the "general TList usage level" not a specific usage. Sorry if I did not write it like that.