easy way to change object position in list?
BlitzMax Forums/BlitzMax Programming/easy way to change object position in list?
| ||
Hi all, I want to change the order of objects in my linked list. Is there a really easy way of doing this? |
| ||
You could manually modify the _succ and _pred Fields of the TLink |
| ||
How would I do this? sorry I'm not very experienced in bmax yet. |
| ||
I was thinking on it and you don't really need to mess around with the _pred and _succ fields at all. Just the value |
| ||
how about... |
| ||
Thanks lads that looks great :) SwapLinks looks good. How do I find the current link? I saw a command called FindLink but I am not sure how to use it. Ideally I'd use this function: Function SwapLinks(Link1:TLink, Link2:TLink) Local tempVal:Object tempVal = Link1._value Link1._value = Link2._value Link2._value = tempVal End Function And just pass the two links in and it should work? Or am I way off base? |
| ||
And just pass the two links in and it should work? Or am I way off base? That's pretty much how you would use it. The problem with using findlink is that you need to have a variable that points to the object you want to find in the first place. The easiest way to do it is as I have in SwapNums, that is, loop through the list and compare each TLinks until you find the ones you need. |