Dynamic arrays in D 1.0
Bill Baxter
dnewsgroup at billbaxter.com
Mon May 12 13:07:41 PDT 2008
Christopher Wright wrote:
> Bill Baxter wrote:
>> Edward Diener wrote:
>>> In D 1.0 dynamic arrays are the equivalent of C++'s std::vector<T>,
>>> with slicing replacing iterators in order to access some subrange of
>>> the sequence. In C++ there is functionality in std::vector::erase for
>>> erasing elements from the vector and std::vector::insert for
>>> inserting new elements into the vector. Where is that functionality
>>> in D's dynamic arrays ?
>>
>> Yes, erase & insert and many other things are conspicuously missing
>> from D1 Phobos (not sure about D2 Phobos). I like the collection of
>> such routines provided by the Cashew library in the cashew.utils.Array
>> module.
>
> I've been using tango's HashSet instead, since I don't need ordering.
> How do the Cashew collections compare?
Oh, Cashew doesn't provide collections. Cashew.utils.Array is just a
bunch of functions for working on D's built-in arrays. Things like
insert, remove, bisection search, etc.
>>> Furthermore in D 1.0 a char[], a dynamic array of characters, is the
>>> equivalent of the C++ std::string. In the C++ std::string class there
>>> is a rich set of functionality for manipulating the char elements in
>>> the string, for finding particular elements in the string, and for
>>> comparing the character elements in strings with other strings, but I
>>> see little of this in dynamic array functionality. What am I missing ?
>>
>> Those functions are in std.string in Phobos. And scattered all over
>> the place in Tango.
>
> If by 'scattered all over the place' you mean 'most everything suitable
> for all array types is in tango.core.Array and everything else is in
> tango.text.*', yes.
I mean the * part of tango.text.*, which consitutes about 30 different
files. Not saying it's a bad design, but it does make it a little
harder for me to find things.
--bb
More information about the Digitalmars-d
mailing list