Distributed Memory implementation
Chris Wright via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jan 19 11:28:50 PST 2016
On Tue, 19 Jan 2016 10:09:01 +0000, Ola Fosheim Grøstad wrote:
> On Monday, 18 January 2016 at 05:59:15 UTC, tcak wrote:
>> Is there anything like this in Phobos, or shall I start my own
>> implementation?
>
> It isn't really clear to me what you are trying to do. IIRC the C++
> deque is usually implemented as an array of pointers to fixed sized
> memory blocks.
>
> Is that what you are trying to achieve?
It's a rope-style data structure, but for void[] rather than strings.
https://en.wikipedia.org/wiki/Rope_(data_structure)
An interesting property of this is that, while you can issue pointers to
memory within this rope, it takes caution to ensure that a pointer
remains within the rope. Instead of just incrementing the pointer, you
would need to call a function on the rope to ensure that it promotes the
pointer to the next memory segment as appropriate.
This also means you can't store a multibyte object in the rope and use it
in place. (Consider: the first block is one byte, the second is seven
bytes; you store a ulong in the rope.) You must always copy it out, use
it, and optionally store it back.
A friendly API would have convenience methods for mutating structured
data within the rope.
This is why just using joiner isn't that friendly, even if joiner did
have opSlice, opIndex, etc.
More information about the Digitalmars-d
mailing list