Associative array key order

Daniel Kozak kozzi11 at gmail.com
Wed Jul 31 08:00:32 PDT 2013


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.
>
> There is a good chance that if you rely on key order, you don't 
> really need an AA but plain array of key-value tuples instead.


Thanks I will use plain array, it is not perfect but better than 
nothing :)


More information about the Digitalmars-d-learn mailing list