Preperly using remove link.
BlitzMax Forums/BlitzMax Beginners Area/Preperly using remove link.
| ||
I've read that removelink is much faster than listremove. I'm pretty used to listremove but I'm not quite sure how to remove a random link from a list using removelink. I really need speed here because my lists are very long. Thanks for any help. Currently I'm using the following method: ListRemove(word_list,TLink(word_list.valueatindex(Rand(0,length-1)))) |
| ||
The ListAddLast method returns a TLink, so if you were to store that, then you could remove it directly using RemoveLink(). So you could setup your type like this: Type TWords Global wordlist:TList Field word:String Field wlink:TLink Function newWord(word:String) Local tmp:TWords = New TWords tmp.word = word tmp.wlink = ListAddLast(wordlist,tmp) End Function Function remove(tmp:TWords) RemoveLink(tmp.wlink) End Function End Type This is untested, just typed directly, but it might get you further on, otherwise I am sure someone else can pitch in and correct it :) |
| ||
Ahhh I see now.. |
| ||
Or this way: http://blitzbasic.com/Community/posts.php?topic=80441#905043 (The postings from dmaz) |