Steve, afaik, depending upon the hash implementation, the only advantage might be moderately faster lookup but the cost in generality often would outweigh that.
On Thursday, January 14, 2016 at 10:44:01 PM UTC-5, [email protected] wrote: > > Could I ask what would be an application of this capability (if it were > possible)? -- Steve Vavasis > > On Wednesday, January 13, 2016 at 3:59:57 PM UTC-5, Ritchie Lee wrote: >> >> As I understand it, Julia dicts use Base.hash when storing custom types >> as keys. Is there a way to look up based on the hash alone? >> >> e.g., >> >> type MyType >> a::Int >> end >> >> Base.hash(x::MyType) = hash(x.a, hash(MyType)) >> >> x = MyType(1) >> D = Dict{MyType, Bool}() >> D[x] = true >> >> Now, is there a way to lookup using h only? >> >> h = hash(x) >> D[h] >> >> Is this be safe to do? >> >> Thanks! >> >
