AA deterministic order ?

cym13 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Nov 25 12:51:32 PST 2015


On Wednesday, 25 November 2015 at 20:24:25 UTC, user-6431 wrote:
> I know that AA items order does not follow the additions but is 
> the order deterministic ?
>
> For example for a given set of items, will they always be 
> ordered in the same way ? (I mean whatever is the way I append 
> them to the AA).

Minimal example showing a collision:

void main() {
     import std.array;

     int[int] aa_1;
     int[int] aa_2;

     aa_1[0] = 42;
     aa_1[8] = 42;

     aa_2[8] = 42;
     aa_2[0] = 42;

     assert(aa_1.byKey.array == [0, 8]);
     assert(aa_2.byKey.array == [8, 0]);
}



More information about the Digitalmars-d-learn mailing list