www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10269] New: RandomSample should use popFrontExactly, not popFrontN, when skipping across input range

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

           Summary: RandomSample should use popFrontExactly, not
                    popFrontN, when skipping across input range
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: joseph.wakeling webdrake.net



2013-06-04 10:00:22 PDT ---
When RandomSample skips across the input range it currently uses

    _input.popFrontN(s);

This should be changed to popFrontExactly for faster performance.  The value of
s is guaranteed to be less than the number of elements remaining in _input,
except in the case where the user has mistakenly provided too large a value.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 04 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10269




Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/8da0f13596125478b8c3c71ae7fecbe5626fb076
Issue 10269 - RandomSample should use popFrontExactly, not popFrontN, when
skipping across input range

This small tweak has been accompanied by a couple of extra checks
to ensure that users do not request more sample points than are
available in the input, which could otherwise be the source of
exceptions.

There exists one remaining case where RandomSample may fail: if it
is given an InputRange without the .length property, and the user
indicates that the total number of items available is greater
than what the InputRange actually contains.  In this case an
exception is thrown from std.array.popFront() line 450,
"Attempting to popFront() past the end of an array", or from
std.array.front() line 624, "Attempting to fetch the front of an
empty array."

https://github.com/D-Programming-Language/phobos/commit/201e5c2dd17e6c8f151c01276a2545c4d7e0d372


Issue 10269 - RandomSample should use popFrontExactly, not popFrontN ...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 16 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10269


Joseph Rushton Wakeling <joseph.wakeling webdrake.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 19 2013