-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|78|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Article Home -> Advanced Techniques


 
Pixel_Outlaw
Created : 02 July 2025
Edited : 03 July 2025

[BMX] Custom For Loop Iterators



Here is an example of how to implement your own Iterator for BlitzMax NG for loops.
I've never seen somebody do this so I present it here.

The For loops are designed this way and left open to the user such that you can make your own kind of iterator.
This is a very common technique in other languages too. Especially C++, Java, C#, Rust - Anything with loops and an iterator interface.

Beyond simple generators like below, it also provides a mechanism to use For loops with any new type of collection you define (think things like Red/Black trees, R-Trees etc)


 

Comments