www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5808] New: std.string.indexOf enhancement with start-at parameter

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5808

           Summary: std.string.indexOf enhancement with start-at parameter
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: ruzicic.aleksandar gmail.com



2011-04-03 20:53:13 CEST ---
Other languages/libraries have start_index as an optional parameter used to
start search at, in their versions of indexOf function.

currently, signature of indexOf is:

sizediff_t indexOf(Char)(in Char[] s, dchar c, CaseSensitive cs =
CaseSensitive.yes);

and desired is:

sizediff_t indexOf(Char)(in Char[] s, dchar c, CaseSensitive cs =
CaseSensitive.yes, sizediff_t sp = 0);

where sp stands for "starting position" and is from where search will start.
Negative indices -N should also be allowed to be able to search a char only in
last N characters of the string.

Example implementation of this parameter (it's really simple addition) can be
found here: https://gist.github.com/900589
Note: if this gets copied to Phobos without changing, it must be properly
tested, since I wrote it just as a quick example...

Also, it would be great if this variation of indexOf template is added (which
can be seen in the gist link above):

sizediff_t indexOf(Char, T = sizediff_t)(in Char[] s, dchar c, T sp = 0)
if (isSomeChar!Char)
{
    return indexOf(s, c, CaseSensitive.yes, sp);
}

since it allows to skip case sensitivity parameter when not needed (which is
mostly the case).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 03 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5808


Aleksandar Ruzicic <ruzicic.aleksandar gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 03 2011