Lazy concatenation and padding utilities
Ilya Yaroshenko via Digitalmars-d
digitalmars-d at puremagic.com
Thu Mar 9 01:55:37 PST 2017
On Thursday, 9 March 2017 at 09:10:47 UTC, Nordlöw wrote:
> On Thursday, 9 March 2017 at 08:59:28 UTC, Ilya Yaroshenko
> wrote:
>> Ndslice got [1] lazy multidimensional concatenation and
>> padding utilities:
>
> Nice. Is this dependent on choosing either RC- or GC-based
> allocation?
No, they are completely generic.
The new ndslice uses iterators under the hood. An iterator for
manually allocated memory (with `makeSlice!T`) and GC allocated
memory (with `slice!T`) is just a pointer type of T*.
You can use `slicedField` [1] to create ndslice on top of a
RC-array. slicedField will create iterator on top of the rc-array
using FieldIterator [2], and return ndslice based on the
iterator. This is quite simple
RC arrays can be very simple: only `auto ref opIndex(size_t
index)` and `length` are required. `front`, `opSlice` and other
RAR primitives are not used by FieldIterator.
[1]
http://docs.algorithm.dlang.io/latest/mir_ndslice_slice.html#slicedField
[2]
http://docs.algorithm.dlang.io/latest/mir_ndslice_iterator.html#FieldIterator
More information about the Digitalmars-d
mailing list