RowCol pair to start enumeration from, inclusive
RowCol pair to end enumeration at, exclusive
import std.algorithm : equal; assert(RowCol(0,0).span(RowCol(2,3)).equal([ RowCol(0,0), RowCol(0,1), RowCol(0,2), RowCol(1,0), RowCol(1,1), RowCol(1,2)])); assert(RowCol(2,2).span(RowCol(0,0)).equal([ RowCol(2,2), RowCol(2,1), RowCol(1,2), RowCol(1,1)])); assert(RowCol(2,2).span(RowCol(1,3)).equal([RowCol(2,2)])); assert(RowCol(2,2).span(RowCol(3,1)).equal([RowCol(2,2)])); // as the upper bound of span is exclusive, both of these are empty (span over 0 columns): assert(RowCol(2,2).span(RowCol(2,2)).empty); assert(RowCol(2,2).span(RowCol(5,2)).empty);
Enumerate all row/col pairs spanning the rectangle bounded by the corners start and end.
The order of enumeration is determined as follows: Enumerate all columns in a row before moving to the next row. If start.row >= end.row, enumerate rows in increasing order, otherwise enumerate in decreasing. If start.col >= end.col, enumerate cols in increasing order, otherwise enumerate in decreasing.