[Issue 8405] Create overload for joiner which is random access for random access ranges
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Nov 10 01:50:31 PST 2014
https://issues.dlang.org/show_bug.cgi?id=8405
--- Comment #5 from bearophile_hugs at eml.cc ---
(In reply to John Colvin from comment #4)
> Unless there is an exploitable pattern in the lengths (rectangular being the
> easiest case), given a NxM range of ranges, it's still O(N).
If you store the row lengths into an array, and you perform a cumulative of
this array, you can perform a binary search on it, to access in O(ln n). At
run-time it can also spot the common case of rectangular matrix, and use a O(1)
code path for that case.
> Perhaps what we need is a generalisation of length for Ranges of Ranges (of
> Ranges ...), called `dimensions` (or `dims`, or `shape`, or whatever seems
> best),
This is Issue 13685 (and it's an easy structure to implement).
--
More information about the Digitalmars-d-bugs
mailing list