I propose the possibility of creating a separate iterator type that can be used with lists or maps.
Similar solutions were made in the past when v4.00 of PureBasic was created. Remember the UseImage(), UseFile(), etc. that were removed in v4.00. Those changes made to v4.00 made it possible to access more than one object in those respective libraries at the same time. Something similar is needed for the LinkedList and Map librairies.
An iterator solution could take this form:
Code: Select all
NewList a.i()
AddElement(a()): a() = 1
AddElement(a()): a() = 5
AddElement(a()): a() = 3
;create an iterator which creates a pointer to a header for a list or map of a given type, but with its own current element
NewListIterator x.i() ;or NewMapIterator
;initialize the iterator to point to a specific list or map, this allows it to service more than one list or map of the same type
SetListIterator(x(), a()) ;or SetMapIterator
ResetList(x()) ;this would reset the current element in x(), not a()
While NextListElement(x())
Debug a() + x() ;would display results for 3 + 1, 3 + 5, 3 + 3
Wend
;another example
ForEach x()
ForEach a()
If a() = x()
Debug a() ;should display 1, 5, 3
EndIf
Next
Next
@Edit: corrected spelling of iterator.
