Navigating tradeoffs in bidirectional filter design

Salih Dincer salihdb at hotmail.com
Fri Jan 10 02:47:24 UTC 2025


On Thursday, 9 January 2025 at 21:56:59 UTC, monkyyy wrote:
> Im aware phoboes takes ....more complexity to implement filter 
> and there should be *some* extra complexity to make a 
> bidirectional filter, but when I ussally look into phoboes 1000 
> line functions I usually make different tradeoffs. What are the 
> actual considerations here?

I don't really understand, what needs to be considerations? Isn't 
the interface below sufficient?

```d
auto filter(alias F,R)(R r)
{
   struct Filter
   {
     R r;
     auto back()     => r.back;
     auto front()    => r.front;
     auto popFront() => r = r.findNext!F;
     auto popBack()  => r = r.findPrevious!F;
     auto empty()    => r.empty;
     auto save()     => r.save;
   }
   return Filter(r.find!F);
}
```

SDB at 79


More information about the Digitalmars-d-learn mailing list