In general, who should do more work: popFront or front?
surlymoor via Digitalmars-d-learn Mon, 14 Jun 2021 21:25:41 -0700
All my custom range types perform all their meaningful work in
their respective popFront methods, in addition to its expected
source data iteration duties. The reason I do this is because I
swear I read in a github discussion that front is expected to be
O(1), and the only way I can think to achieve this is to stash
the front element of a range in a private field; popFront would
thus also set this field to a new value upon every call, and
front would forward to it. (Or front would be the cache itself.)
At the moment, I feel that as long as the stashed front element
isn't too "big" (For some definition of big, I guess.), that
built-in caching should be fine. But is this acceptable? What's
the best practice for determining which range member should
perform what work? (Other than iterating, of course.)
- In general, who should do more work: ... surlymoor via Digitalmars-d-learn
- Re: In general, who should do mo... jfondren via Digitalmars-d-learn
- Re: In general, who should d... surlymoor via Digitalmars-d-learn
- Re: In general, who should do mo... mw via Digitalmars-d-learn
- Re: In general, who should d... surlymoor via Digitalmars-d-learn
- Re: In general, who shou... mw via Digitalmars-d-learn
- Re: In general, who ... surlymoor via Digitalmars-d-learn
- Re: In general, who ... ag0aep6g via Digitalmars-d-learn
- Re: In general, who ... Ali Çehreli via Digitalmars-d-learn
- Re: In general, who should do mo... Mike Parker via Digitalmars-d-learn
- Re: In general, who should do mo... Paul Backus via Digitalmars-d-learn