Class EqualObjectGraphs

java.lang.Object
org.htmlunit.corejs.javascript.EqualObjectGraphs

final class EqualObjectGraphs extends Object
An object that implements deep equality test of objects, including their reference graph topology, that is in addition to establishing by-value equality of objects, it also establishes that their reachable object graphs have identical shape. It is capable of custom-comparing a wide range of various objects, including various Rhino Scriptables, Java arrays, Java Lists, and to some degree Java Maps and Sets (sorted Maps are okay, as well as Sets with elements that can be sorted using their Comparable implementation, and Maps whose keysets work the same). The requirement for sortable maps and sets is to ensure deterministic order of traversal, which is necessary for establishing structural equality of object graphs.

An instance of this object is stateful in that it memoizes pairs of objects that already compared equal, so reusing an instance for repeated equality tests of potentially overlapping object graph is beneficial for performance as long as all equality test invocations returns true. Reuse is not advised after an equality test returned false since there is a heuristic in comparing cyclic data structures that can memoize false equalities if two cyclic data structures end up being unequal.