Bug 8866 – Splitter(R1, R2) CANNOT be bidirectional.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-10-22T03:08:00Z
Last change time
2015-06-09T05:14:45Z
Assigned to
nobody
Creator
monarchdodra

Comments

Comment #0 by monarchdodra — 2012-10-22T03:08:00Z
Because long story short: If a splitter "element" overlaps with another, the the orientation of the splitting will influence the splitting. For example: Given the string "aaab", and the splitter "ab": //---- import std.string; import std.algorithm; import std.range; import std.stdio; void main() { auto r = "aaab"; auto sep = "aa"; auto s = r.splitter(sep); //Normal split s.writeln(); //Split using back/popBack: s.retro().array().retro().writeln(); } //---- Produces: ["", "ab"] ["a", "b"] This creates two different results. I don't have a source for this, but I'm 99% sure that iterating a range backwards should produce the same output as the reverse of the range iterated forward. Suggest removing backwards iteration on splitter(R1, R2), and add suggestion to use splitter(R1.retro, R2.retro) ---- Note; splitter(R, Value) and splitter(terminator)(R) should be able to safely iterate backwards.
Comment #1 by github-bugzilla — 2014-07-27T19:53:35Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/9d158ba52d109fceacb64dac0af17bfd80ed7395 Fix Issue 8866 - Splitter(R1, R2) CANNOT be bidirectional. https://github.com/D-Programming-Language/phobos/commit/c48f9c56f1a1a26d34f5fd99a90843613bb24116 Merge pull request #1475 from monarchdodra/issue8866 Fix Issue 8866 - Splitter(R1, R2) CANNOT be bidirectional.