Typo: "Attenpting" (at least two places)
I think popBack for bidirectional ranges is broken. Consider I have a
range of 1000 elements and I take 5 of them. Then popBack would have to
back off 996 elements. That is not what your code is doing, and it would
not satisfy the complexity requirements of popBack.
Please keep the popBack code only for random-access ranges.
Thanks,
Andrei
On 05/29/2010 08:44 AM, dsource.org wrote:
phobos commit, revision 1566
user: rsinfu
msg:
Fixed bugzilla 3876: std.range.Take back/popBack methods don't work correctly.
Thanks to Philippe Sigaud for the proposed solution. It was helpful.
The former implementation simply used input.back for Take.back. It didn't work
if input.length was larger than maxAvailable. For example:
input = [ 1, 2, 3, 4, 5 ]
s = take(input, 3) // [ 1, 2, 3 ]
s.back == input.back == 5 // wrong!
Take must pop all the excess elements from the input ([4,5] in the above
example) to provide correct back element. This change makes it to do so if
input is purely bidirectional. (random access is used instead if possible.)
- Added Take.opSlice
- Added some enforcement error messages
http://www.dsource.org/projects/phobos/changeset/1566
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos