Use cases for IdentityHashMap

后端 未结 7 695
谎友^
谎友^ 2020-12-12 13:31

Could anyone please tell what are the important use cases of IdentityHashMap?

7条回答
  •  失恋的感觉
    2020-12-12 14:19

    The documentations says:

    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.

提交回复
热议问题