Package org.zkoss.util
Class IdentityComparator<T>
- java.lang.Object
-
- org.zkoss.util.IdentityComparator<T>
-
- All Implemented Interfaces:
java.util.Comparator<T>
public class IdentityComparator<T> extends java.lang.Object implements java.util.Comparator<T>
The comparator uses == and System.identifyHashCode to compare two objects. It assumes if o1 != o2, then c1 != c2 where c1 = System.identityHashCode(o1).This is useful if dynamic proxy is used with TreeSet or TreeMap (so equals is expensive). Reason: the speed of identifyHashCode is much faster than dynamic proxy (150:1).
However, if possible, java.util.IdentityHashMap and
IdentityHashSet
are preferred.- Author:
- tomyeh
- See Also:
IdentityHashSet
-
-
Constructor Summary
Constructors Constructor Description IdentityComparator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(T o1, T o2)
-