associative arrays

Jonathan M Davis jmdavisProg at gmx.com
Mon Jan 9 09:50:51 PST 2012


On Monday, January 09, 2012 09:25:14 Steven Schveighoffer wrote:
> Actually, not invalid for the current implementation. I don't know if
> it's stated whether an AA specifically requires that elements do not
> re-associate on a rehash.

Well, like I said, it depends on the current implementation. There are hash 
table implementations where rehashing would invalidate the pointer returned by 
in, and I don't believe that the spec specificies that D's AA guarantees that 
rehashing doesn't do that. So in the future, it _could_ be changed to an 
implementation which invalidates the pointers on rehash. As such, it doesn't 
really matter what the current implementation does. Relying on the current 
behavior is unsafe if it's not guaranteed by the spec. Now, if we want to 
change the spec to make such guarantees, that's fine, but I don't believe it 
makes them right now. Good to know what the current implementation is doing 
though.

- Jonathan m Davis


More information about the Digitalmars-d-learn mailing list