org.zkoss.util
Class IdentityComparator
java.lang.Object
org.zkoss.util.IdentityComparator
- All Implemented Interfaces:
- java.util.Comparator
public class IdentityComparator
- extends java.lang.Object
- implements java.util.Comparator
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
Method Summary |
int |
compare(java.lang.Object o1,
java.lang.Object o2)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
equals |
IdentityComparator
public IdentityComparator()
compare
public int compare(java.lang.Object o1,
java.lang.Object o2)
- Specified by:
compare
in interface java.util.Comparator
Copyright © 2005-2009 Potix Corporation. All Rights Reserved.