Dynamic array + AA array

Paul Backus snarwin at gmail.com
Tue Sep 17 14:59:57 UTC 2019


On Tuesday, 17 September 2019 at 14:33:30 UTC, Brett wrote:
> The idea is to basically use a dynamic array for most of the 
> items, then an array to get the rest.
>
> T[] Base;
> T[int] Rest;
>
> Then if Base has a max size(usually it might be fixed due to 
> some algorithm) the Rest AA can pick up any outside values 
> easily.
>
> The idea here is to be able to combine them as one "infinite" 
> array of T.
>
> Any indexing outside of Base gets carried in to Rest.
>
> Now the question is, is there any way to wrap all this in to 
> dynamic array semantics easily?

You can create a wrapper type for this that supports indexing, 
slicing, etc. using D's operator overloading:

https://dlang.org/spec/operatoroverloading.html


More information about the Digitalmars-d-learn mailing list