Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
January 30, 2011 [Issue 5507] New: countUntil should take Ranges... instead of R2 | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5507 Summary: countUntil should take Ranges... instead of R2 Product: D Version: D2 Platform: Other OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: andrei@metalanguage.com ReportedBy: Jesse.K.Phillips+D@gmail.com CC: Jesse.K.Phillips+D@gmail.com --- Comment #0 from Jesse Phillips <Jesse.K.Phillips+D@gmail.com> 2011-01-30 11:18:23 PST --- The recent addition of countUntil makes use of the startsWith template function which has an overload for accepting many ranges. By modifying the signature you can take advantage of this overload at no additional code: - sizediff_t countUntil(alias pred = "a == b", R1, R2)(R1 haystack, R2 needle) + sizediff_t countUntil(alias pred = "a == b", R1, Ranges...)(R1 haystack, Ranges needle) https://github.com/D-Programming-Language/phobos/blob/master/std/algorithm.d#L3239 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 31, 2011 [Issue 5507] countUntil should take Ranges... instead of R2 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5507 Andrei Alexandrescu <andrei@metalanguage.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 15, 2012 [Issue 5507] countUntil should take Ranges... instead of R2 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5507 monarchdodra@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |monarchdodra@gmail.com --- Comment #1 from monarchdodra@gmail.com 2012-11-15 05:31:27 PST --- (In reply to comment #0) > The recent addition of countUntil makes use of the startsWith template function which has an overload for accepting many ranges. By modifying the signature you can take advantage of this overload at no additional code: > > - sizediff_t countUntil(alias pred = "a == b", R1, R2)(R1 haystack, R2 needle) > + sizediff_t countUntil(alias pred = "a == b", R1, Ranges...)(R1 haystack, > Ranges needle) > > https://github.com/D-Programming-Language/phobos/blob/master/std/algorithm.d#L3239 While the new signature *would* be nice to have, this actually *would* make count until much more complex: startsWith only cares about the beginning of the ranges, and as such, is perfectly capable of operating on input+input ranges. By contrast, countUntil *Needs* to have Forward+Forward 1. This makes the "if(is(typeof(startsWith(haystack, needles))))" a bad condition Also, since startsWith "consumes" its inputs, the ranges passed to it need to be saved. 2. This would require a lot of code, to analyze just what in needle is a range (that needs saving) or is an element (that doesn't). Not saying it's a bad idea, or that it can't happen, but it requires *much* more than a simple signature change. For now (IMHO), we should concentrate on consolidating the current implementati -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 10, 2013 [Issue 5507] countUntil should take Ranges... instead of R2 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5507 Brad Anderson <eco@gnuk.net> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |eco@gnuk.net --- Comment #2 from Brad Anderson <eco@gnuk.net> 2013-01-10 09:33:35 PST --- Hit this answering a StackOverflow question <http://stackoverflow.com/q/14262766/216300>. My solution (using countUntil() on the result of find() with multiple needles) requires two passes which is unfortunate since there should only need to be one pass. There is probably a way to avoid this that I didn't see but whatever it is is probably just as convoluted as my solution. countUntil should really just accept multiple needles so consider this my +1. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 10, 2013 [Issue 5507] countUntil should take Ranges... instead of R2 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5507 Jonathan M Davis <jmdavisProg@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jmdavisProg@gmx.com Severity|normal |enhancement -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 25, 2013 [Issue 5507] countUntil should take Ranges... instead of R2 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5507 Alex Rønne Petersen <alex@lycus.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED CC| |alex@lycus.org Resolution| |FIXED --- Comment #3 from github-bugzilla@puremagic.com 2013-02-24 16:50:17 PST --- Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/d7dd280e39a8f4e18b836853df7e19079e2cec62 issue 5507 https://github.com/D-Programming-Language/phobos/commit/54ddafa1a8d24e5225051280e87b0926bdbcd1ee Merge pull request #1166 from andralex/5507 Fix Issue 5507 - countUntil should take Ranges... instead of R2 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 25, 2013 [Issue 5507] countUntil should take Ranges... instead of R2 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5507 Alex Rønne Petersen <alex@lycus.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED CC| |alex@lycus.org Resolution| |FIXED --- Comment #3 from github-bugzilla@puremagic.com 2013-02-25 01:50:17 CET --- Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/d7dd280e39a8f4e18b836853df7e19079e2cec62 issue 5507 https://github.com/D-Programming-Language/phobos/commit/54ddafa1a8d24e5225051280e87b0926bdbcd1ee Merge pull request #1166 from andralex/5507 Fix Issue 5507 - countUntil should take Ranges... instead of R2 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation