[Issue 13936] groupBy must be redone

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Jan 12 11:58:59 PST 2015


https://issues.dlang.org/show_bug.cgi?id=13936

--- Comment #27 from hsteoh at quickfur.ath.cx ---
Anyway, another design occurred to me. For ranges with slicing, we could scan
Groups in advance and just return slices from .front. The predicate only needs
to be evaluated once per element pair. This can be extended to non-sliceable
ranges by precomputing the length of each Group in advance: then Group.popFront
won't need to evaluate the predicate again (just decrement the length), whereas
now if you iterate over 10 copies of each Group, each one will have to evaluate
the predicate each time.

--


More information about the Digitalmars-d-bugs mailing list