persistable sclass FloodFill is Steppable { // input int w, h; swappable bool isConnectable(Pt a, Pt b) { throw unimplemented(); } void visited(Pt p) {} // internal new L stack; BitMatrix visited = new BitSetMatrix; *(int *w, int *h) {} bool isPointVisited(Pt p) { ret visited.get(p); } void startAt aka addPoint(Pt p) { if (p.x < 0 || p.y < 0 || p.x >= w || p.y >= h) ret; if (isPointVisited(p)) ret; stack.add(p); } public bool step() { if (empty(stack)) false; Pt p = popLast(stack); int x = p.x, y = p.y; visited.set(p, true); visited(p); possibleBridge(p, new Pt(x-1, y)); possibleBridge(p, new Pt(x+1, y)); possibleBridge(p, new Pt(x, y-1)); possibleBridge(p, new Pt(x, y+1)); true; } void possibleBridge(Pt a, Pt b) { if (isConnectable(a, b)) { addPoint(b); createBridge(a, b); } } void createBridge(Pt a, Pt b) {} }