An IdentityMap is like WeakHashMap, except it uses a key's identity hashcode and equals methods. IdentityMap is not thread-safe and must be wrapped with Collections.synchronizedMap to be made thread-safe. Most of the implementation for this class is ripped off from java.util.HashMap, but not java.util.WeakHashMap, in order to acheive greater efficiency.
The documentation for WeakHashMap states that it is intended primarily for use with key objects whose equals methods test for object identity using the == operator. Because WeakHashMap uses a key's own equals and hashcode methods, it is better suited for implementing methods that behave like {@link String#intern}. However, because WeakHashMap stongly references values, {@link Utils#intern Utils.intern} provides a safer intern mechanism.
In this implementation, all key objects are tested for equality using the == operator, and null keys are not permitted. IdentityMap is therefore better suited for "canonicalized" mappings.
Note: Weakly referenced entries may be automatically removed during either accessor or mutator operations, possibly causing a concurrent modification to be detected. Therefore, even if multiple threads are only accessing this map, be sure to synchronize this map first. Also, do not rely on the value returned by size() when using an iterator from this map. The iterators may return less entries than the amount reported by size().
@author Brian S O'Neill
@version 19 , 00/12/18
@see java.util.WeakHashMap
@see java.util.HashMap