[phobos] Transversal/Transposed
David Simcha
dsimcha at gmail.com
Sun Aug 7 18:06:42 PDT 2011
Last year, when I was cleaning up/debugging std.range, one issue I never
got around to addressing was Transposed. Currently it's completely
undocumented even though it could be highly useful. To get it up to
snuff, I think I need to convert FrontTransversal into EndTransversal.
EndTransversal would decide at runtime via an enum whether to iterate
the front or back of the range of ranges:
auto ror = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
auto frontTrans = endTransversal(ror, TransversalType.front);
assert(equal(frontTrans, [1, 4, 7]));
auto backTrans = endTransversal(ror, TransversalType.back);
assert(equal(backTrans, [3, 6, 9]));
This would come at a small performance cost, since every call to
EndTransversal.front would need to decide whether to fetch the front or
back of each range. It would not be possible to decide this at compile
time because Transposed.back and Transposed.front need to return the
same type.
Since this is going to require significant effort, is everyone on board
with it before I get busy?
More information about the phobos
mailing list