⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 identitycomparator.java

📁 非常接近C/S操作方式的Java Ajax框架-ZK 用ZK框架使你的B/S应用程序更漂亮更易操作。 官网:www.zkoss.org
💻 JAVA
字号:
/* IdentityComparator.java{{IS_NOTE	Purpose:		The comparator uses == and System.identifyHashCode to do		the comparison.	Description:			History:		Fri Sep 13 10:14:11  2002, Created by tomyeh}}IS_NOTECopyright (C) 2002 Potix Corporation. All Rights Reserved.{{IS_RIGHT	This program is distributed under GPL Version 2.0 in the hope that	it will be useful, but WITHOUT ANY WARRANTY.}}IS_RIGHT*/package org.zkoss.util;import 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). * * <p>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). * * <p>However, if possible, java.util.IdentityHashMap and {@link IdentityHashSet} * are preferred. * * @author tomyeh * @see IdentityHashSet */public class IdentityComparator implements Comparator {	public IdentityComparator() {	}	//-- Comparator --//	public int compare(Object o1, Object o2) {		if (o1 == o2)			return 0;		int c1 = System.identityHashCode(o1);		int c2 = System.identityHashCode(o2);		assert c1 != c2; //if o1 != o2, c1 != c2		return c1 > c2 ? 1: -1;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -