Does anyone have an implementation of an IdentitySet, possibly derived from a LinkedHashSet? I found a good looking version of an IdentityHashMap at https://gist.githubusercontent.com/jdolson/1566619/raw/70c06ed174862363df8dcd75f86acddc0b8349f4/IdentityHashMap.scala and suspect there can be a similar Set with methods like elemEquals, elemHashCode, and maybe IdentityHashSet overridden. It seems like the class would be described as
class IdentityHashSet[A <: AnyRef]() extends LinkedHashSet[A] with GenericSetTemplate[A, IdentityHashSet]
with SetLike[A, IdentityHashSet[A]] with HashTable[A, IdentityHashSet.Entry[A]] {
but that GenericSetTemplate[A, IdentityHashSet]
isn’t quite normal in that IdentityHashSet would seem to require an A or something.
Versions without it will compile, but I wouldn’t know to what extent they don’t do everything required.
I do not want to wrap every value in a wrapper that has redefined equals. This is for Scala 2.12 and 2.11. Maybe the newer version have something already.