Function span
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.
Prototypes
auto std.algorithm. iteration. __T9MapResultS756dtiled6coords4spanFS6dtiled6coords6RowColS6dtiled6coords6RowColZ9__lambda3TS3std9algorithm6setops114__T16cartesianProductTS3std5range15__T4iotaTlTlTlZ4iotaFlllZ6ResultTS3std5range15__T4iotaTlTlTlZ4iotaFlllZ6ResultZ16cartesianProductFS3std5range15__T4iotaTlTlTlZ4iotaFlllZ6ResultS3std5range15__T4iotaTlTlTlZ4iotaFlllZ6ResultZ6ResultZ. MapResult span( RowCol start, RowCol end ); auto std. algorithm. iteration. __T9MapResultS756dtiled6coords4spanFS6dtiled6coords6RowColS6dtiled6coords6RowColZ9__lambda3TS3std9algorithm6setops114__T16cartesianProductTS3std5range15__T4iotaTlTlTlZ4iotaFlllZ6ResultTS3std5range15__T4iotaTlTlTlZ4iotaFlllZ6ResultZ16cartesianProductFS3std5range15__T4iotaTlTlTlZ4iotaFlllZ6ResultS3std5range15__T4iotaTlTlTlZ4iotaFlllZ6ResultZ6ResultZ. MapResult span( RowCol start, long endRow, long endCol );
Parameters
Name | Description |
---|---|
start | RowCol pair to start enumeration from, $(B inclusive) |
end | RowCol pair to end enumeration at, $(B exclusive) |
Example
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);