Variable chunk sizes operations
Mihaela Chirea
chireamihaela99 at gmail.com
Sun Aug 30 17:24:02 UTC 2020
On Sunday, 30 August 2020 at 04:32:17 UTC, 9il wrote:
> On Saturday, 29 August 2020 at 23:33:49 UTC, Mihaela Chirea
> wrote:
>> I started working on this issue and I reached a point where
>> some more opinions would be needed:
>>
>> https://github.com/dlang/phobos/pull/7600
>
> Mir solution for random-access ranges [1]. It has a slightly
> different API, instead of the chunk sizes, it uses the index
> sequence. Everything is O(1).
>
> [1]
> http://mir-algorithm.libmir.org/mir_ndslice_topology.html#.chopped
Thanks! This would indeed solve the indexing and slicing problem.
But back and popBack would still have to search for the last
valid index. At the moment, when the source range is too short,
the last elements of the lengths range are ignored, so the length
of the range of chunks isn't always equal to the length of the
lengths range.
I was thinking of solving this by just giving empty chunks for
those extra elements.
Does this sound like a good approach? Or maybe throwing an error
would be a better option?
More information about the Digitalmars-d
mailing list