what prevents dynamic array from being deprecated & tuple being

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Apr 4 08:48:03 PDT 2009


bearophile wrote:
> davidl:
>> Something like following can substitute dynamic array:
>> struct da(T){
>>      T* ptr;
>>      int len, capacity;
>>      T opIndex(int i){}
>> ...
> 
> On 32 bit systems that struct is 3*4 bytes long, but the current GC allocates small sizes using blocks of memory long as powers of 2, so I think that struct uses 4*4 bytes anyway. So the 4th word can be used for something else. A good way to use it may be to store there a hash value (by default is 0, that means "hash not computed yet").

Aren't arrays manipulated mostly by value?

Andrei



More information about the Digitalmars-d mailing list