[Issue 4492] Version of take() which takes from the back of a range

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 21 19:16:41 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4492



--- Comment #3 from David Simcha <dsimcha at yahoo.com> 2010-07-21 19:16:35 PDT ---
Two points:

1.  Retro is not inefficient.  For random access, there's the overhead of
translating the index to length - index, but this is negligible in most cases
(though I wouldn't use it in super performance critical numerics code).  In the
case of front(), popFront(), etc., all it does is forward front() to back(),
popFront() to popBack() and vice-versa.  These are virtually guaranteed to be
inlined by the compiler, resulting in truly zero overhead for non-random
access.

2.  Sorry for the misunderstanding on what you expected takeBack to do. 
However, now IIUC takeBack would be unimplementable on non-random access
ranges, unless the range had a length **and** you performed an O(n) seek.  If
you can only access the front and back element of a range at any given time,
you can't get the Nth element from the back.

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


More information about the Digitalmars-d-bugs mailing list