In-place extension of arrays only for certain alignment?
Steven Schveighoffer
schveiguy at gmail.com
Fri Aug 19 12:12:32 UTC 2022
On 8/18/22 1:16 AM, Ali Çehreli wrote:
> On 8/17/22 19:27, Steven Schveighoffer wrote:
> > On 8/17/22 10:09 PM, Ali Çehreli wrote:
> >> > IIRC, your data does not need to be sequential in *physical memory*,
> >> > which means you can use a ring buffer that is segmented instead of
> >> > virtually mapped, and that can be of any size.
> >>
> >> I thought about that as well. But I would like the sizes of blocks
> >> (Appenders?) be equal in size so that opIndex still can provide O(1)
> >> guarantee. (Compute the block + an offset.)
> >
> > It's still O(1). You only have 2 slices to worry about.
>
> Sometimes 2... I wanted to leave the sliding window width dynamic.
>
> So, there will be M buffers, not 2. If their lengths are not equal,
> opIndex must be O(M). M is expected to be small but still...
Once you need more size, you can reallocate (it should stabilize). A
ring buffer of N values where N doesn't change should only require one
buffer, 2 slices of that buffer.
-Steve
More information about the Digitalmars-d-learn
mailing list