Caching in computing ranges

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Mon Oct 11 02:46:09 PDT 2010


On Sat, 09 Oct 2010 18:43:54 -0500, Andrei Alexandrescu wrote:

> On 10/9/10 18:20 CDT, dsimcha wrote:
>> Vote++.  When I added bidirectional support for map(), I felt like any
>> solution for doing bidirectional caching was going to suck.  I
>> considered just eliminating it, but left it because at the time I was
>> more interested in just getting bidirectional/random access working
>> than worrying about the cache issue.  IMHO the only range that should
>> be cached is a Cached higher order range.
> 
> Cached will be quite a story in and of itself. I can tell you for sure
> we need two related abstractions in std.range:
> 
> 1. Lookback!Range provides a history that allows the range to look back
> up to n items:
> 
> auto r = lookback(file.byLine(), 20); ...
> r.lookback(3); // three lines before the current
> 
> 2. Lookahead!Range similarly allows looking ahead:
> 
> auto r = lookahead(file.byLine(), 20); ...
> r.lookahead(3); // three lines after the current
> 
> 
> Andrei


A PushBack!Range that allows 'un-popping' elements could also be useful.

-Lars


More information about the Digitalmars-d mailing list