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 <[email protected]> > To: Discuss the phobos library for D <[email protected]> > Cc: dsource.org <[email protected]> > 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:[email protected]">[email protected] > > http://lists.puremagic.com/mailman/listinfo/phobos _______________________________________________ phobos > mailing list > href="mailto:[email protected]">[email protected] > href="http://lists.puremagic.com/mailman/listinfo/phobos" target=_blank > >http://lists.puremagic.com/mailman/listinfo/phobos _______________________________________________ phobos mailing list [email protected] http://lists.puremagic.com/mailman/listinfo/phobos
