How to optimise out FindLink() from Eachin loop?
BlitzMax Forums/BlitzMax Programming/How to optimise out FindLink() from Eachin loop?
| ||
For b:blah = EachIn blahlist bLink:TLink = blahlist.FindLink(b) Next Is there anyway to get rid of the FindLink()? Hacking into EachIn maybe to get the current TLink object? |
| ||
Use the TListEnumerator This way you can iterate through the TLink construction instead iterating through the values |
| ||
I'll just have to use a While loop instead. Easy answer. |
| ||
Type List Extends TList Field Enum:TListEnum Method ObjectEnumerator:TListEnum() enum=New TListEnum enum._link=_head._succ Return enum End Method Method CurrentLink:TLink() Return enum._link._pred End Method End Type ;) I'd leave it at using it for reading data, not modifying _pred/ _succ handles. I've tried. it didn't work very well. I wrote my own different style list: Enum is public, so just access Enum.Current. |
| ||
Thanks bot. That works nicely. |