I made a vector set in order to avoid thrashing the GC with iterator allocations and the like
( you get a new/free each for both the set reference and the set iterator for each traversal of a HashSet's values or keys )
anyway supposedly the Object.hashCode() method is a unique id per object. (would fail for a 64 bit version?)
But in any case it is overridable and therefore not guaranteed unique, nor unique per object instance.
If I want to create an "ObjectSet" how do I get a guaranteed unique ID for each instance of an object??
I just found this: which answers it.
解决方案
java.lang.System.identityHashCode(obj); will do this for you, if you really need it and understand the repercussions. It gets the identity hashcode, even if the method to provide the hashcode has been overridden.