www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5507] New: countUntil should take Ranges... instead of R2

reply d-bugmail puremagic.com writes:
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



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: -------
Jan 30 2011
next sibling parent d-bugmail puremagic.com writes:
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: -------
Jan 31 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5507


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra gmail.com




 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: -------
Nov 15 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5507


Brad Anderson <eco gnuk.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |eco gnuk.net



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: -------
Jan 10 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
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: -------
Jan 10 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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


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: -------
Feb 24 2013
prev sibling parent d-bugmail puremagic.com writes:
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



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


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: -------
Feb 24 2013