Associative array key order

Daniel Kozak kozzi11 at gmail.com
Fri Aug 23 04:53:13 PDT 2013


When I do some cleanups, I find some bugs and after fixing them, 
my own OrderedAA implementation does not beat builtin hash 
anymore :(. But speed is still really near to builtin AA's.

On Thursday, 22 August 2013 at 07:59:05 UTC, Daniel Kozak wrote:
> On Wednesday, 31 July 2013 at 14:55:55 UTC, Dicebot wrote:
>> On Wednesday, 31 July 2013 at 14:43:21 UTC, Daniel Kozak wrote:
>>> is there a way for AA to behave same as PHP?
>>
>> I doubt it. This snippet suggests that AA's in PHP are not 
>> simply AA's and do additionally track insertion order (or use 
>> some similar trick). Data in associative arrays is organized 
>> in a way that allows fast key lookup and iterating in an 
>> original order requires tracking extra state. Contrary to PHP, 
>> D does care about performance so I see no way this can happen 
>> automatically.
>
> I implemented my own OrderedAA type, which is able to preserve 
> insert order and is a little faster and take less memory(30%) 
> then the builtin one :-).
>
> But definitly there will be some cases where my own 
> implementation doesn't beat the builtin one.


More information about the Digitalmars-d-learn mailing list