[phobos] phobos commit, revision 1566
Steve Schveighoffer
schveiguy at yahoo.com
Sat May 29 07:17:44 PDT 2010
Arguably, Take should never support back and popBack. If you have a random access range, why wouldn't you just do r[0..3]?
-Steve
----- Original Message ----
> From: Andrei Alexandrescu <andrei at erdani.com>
> To: Discuss the phobos library for D <phobos at puremagic.com>
> Cc: dsource.org <noreply at dsource.org>
> Sent: Sat, May 29, 2010 9:54:58 AM
> Subject: Re: [phobos] phobos commit, revision 1566
>
> 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
>
> href="mailto:phobos at puremagic.com">phobos at puremagic.com
>
> http://lists.puremagic.com/mailman/listinfo/phobos
_______________________________________________
phobos
> mailing list
> href="mailto:phobos at puremagic.com">phobos at puremagic.com
> href="http://lists.puremagic.com/mailman/listinfo/phobos" target=_blank
> >http://lists.puremagic.com/mailman/listinfo/phobos
More information about the phobos
mailing list