Possible Duplicate:
Use cases for IdentityHashMap
What could be a practical use of the IdentityHashMap introduced in Java 5?
This class implements the Map interface with a hash table, using reference-equality in place of object-equality when comparing keys (and values). In other words, in an IdentityHashMap, two keys k1 and k2 are considered equal if and only if (k1==k2).
HashMap uses object equality to compare the key and values. IdentityHashMap uses reference equality to compare the key and values.
Features of IdentityHashMapIt is not synchronized and must be synchronized externally. Iterators are fail-fast, throw ConcurrentModificationException in an attempt to modify while iterating.
The IdentityHashMap, WeakHashMap, and EnumMap all are the classes in java collection that implements the Map interface.
Have a look at the Java Docs :-)
A typical use of this class is topology-preserving object graph transformations, such as serialization or deep-copying. To perform such a transformation, a program must maintain a "node table" that keeps track of all the object references that have already been processed. The node table must not equate distinct objects even if they happen to be equal. Another typical use of this class is to maintain proxy objects. For example, a debugging facility might wish to maintain a proxy object for each object in the program being debugged.
On a side note: it's available since version 1.4, not Java 5 or 6...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With