Caching in computing ranges
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sat Oct 9 16:43:54 PDT 2010
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
More information about the Digitalmars-d
mailing list