sclass AbstractFastRegions_ShuffledScan is Steppable { AbstractFastRegions regionMaker; WeightlessShuffledIterator iterator; *(AbstractFastRegions *regionMaker) { regionMaker.init(); iterator = new WeightlessShuffledIterator(regionMaker.size); } public bool step() { ret findNextRegion() > 0; } int findNextRegion() { var regionMatrix = regionMaker.regionMatrix; int pixel; while ((pixel = iterator.nextIndex()) >= 0) if (regionMatrix[pixel] == 0) { regionMaker.runner = pixel; ret regionMaker.makeRegion(); } ret 0; } // null if there are no more regions IImageRegion nextRegion() { int iRegion = findNextRegion(); ret iRegion > 0 ? regionMaker.getRegion(iRegion) : null; } }