Can the order in associative array change when keys are not midified?

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jan 2 05:33:48 PST 2015


On 1/1/15 7:32 AM, Idan Arye wrote:
> If I have an associative array and I only modify it's values, without
> changing the keys, can I assume that the order won't change?

I would never make that assumption. An AA is free to rehash at any time, 
for whatever reason.

What I would say is that you can probably safely assume an AA will 
iterate in the same order as long as it hasn't been changed.

If you need guaranteed ordering, use an array or a RedBlackTree.

-Steve


More information about the Digitalmars-d-learn mailing list