oxbow_lakes
oxbow_lakes

Reputation: 134260

Is there a way of creating an IdentityMap in scala 2.8

There used to be an IdentityHashMap in collection.jcl: is there a way of constructing the same thing in the new 2.8 collections library (perhaps with a bespoke equality-relation)?

Upvotes: 3

Views: 357

Answers (1)

Randall Schulz
Randall Schulz

Reputation: 26486

In scala.collection.mutable.HashMap there are two protected methods, elemEquals and elemHashCode. If you override them you can create an IdentityHashMap of your own.

In scala.collection.immutable.HashMap there is only elemHashCode. (I don't know why, offhand.)

Upvotes: 4

Related Questions