Associative array key order
Daniel Kozak
kozzi11 at gmail.com
Thu Aug 22 00:59:04 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.
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