On Saturday, 2 April 2016 at 14:22:01 UTC, Temtaime wrote:
Hi !
I can't find this in specs.
If i add an element to AA:
aa[10] = 123;
Will &aa[10] be always the same (of course i don't remove that
key) ?
Thanks for a reply.
I think specs should be enhanced.
Running following
int aa[int];
aa[10] = 123;
auto p = &aa[10];
writeln(*p);
aa[11] = 121; // add Element
writeln(*p);
aa[10] = 1; // change Element
writeln(*p);
aa.rehash; // reorganize
writeln(*p);
aa.remove(10);
aa[10] = 3; // remove & add Element
writeln(*p);
results in
123 // correct
123 // correct
1 // correct
1 // correct because I'm lucky
1 // wrong
What Alis said is "rehash", a combination of remove/add or any
other reorganisation, which could change memory usage and data
locations.
By the way...why do you need a pointer to an AA-Element?
Regards, Ozan