Can the order in associative array change when keys are not midified?
Peter Alexander via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jan 1 05:39:56 PST 2015
On Thursday, 1 January 2015 at 13:13:10 UTC, Andrej Mitrovic via
Digitalmars-d-learn wrote:
> On 1/1/15, Idan Arye via Digitalmars-d-learn
> <digitalmars-d-learn at puremagic.com> 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?
>
> Associative arrays are not ordered at all.
>
> See the first note here: http://dlang.org/hash-map.html
The order is unspecified, but an iteration must iterate in *some*
order. The question (if I've understood it correctly), is whether
that order of iteration changes when the keys aren't changed.
The spec doesn't say anything about this, although I would expect
in practice that the order will not change.
I've added a bug to track this omission from the spec:
https://issues.dlang.org/show_bug.cgi?id=13923
More information about the Digitalmars-d-learn
mailing list