Hi,
Is there a straight forward Array type in D similar to C++'s vector class? Something along the lines of the tuple: (pointer to elements, length, capacity).
I tried two implementations: D's dynamic array and std.container.array.
When D creates a dynamic array, it returns a slice. Functions that add or remove elements begin by asking the memory manager for the dynamic array that the slice belongs to. Only then can they go on and add elements.
I switched to std.container.array. It is more straight forward, but is also reference counted. Array is basically a pointer to the tuple (pointer to elements, length, capacity, refCount). Functions that add or remove elements begin by checking that the Array is not null, follow the pointer to the actual tuple, then follow the "pointer to elements" to access the actual elements. In C++, this is similar to shared_ptr<vector>. The documentation does not mention nor explain why. Can someone explain? Is there a simpler, more efficient alternative?
Thanks in Advance,
dhs