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

📄 idcomparator.java

📁 geotools的源码
💻 JAVA
字号:
package uk.ac.leeds.ccg.geotools;
import com.sun.java.util.collections.*; //Change for 1.2

/**
 * An implementation of the collection Comparator interface that allows
 * for the comparing of objects that implement the IDReferenced interface.
 * This can be used in conjenction with the collection packages that support sorting
 * to provide efficient storage and retrival of features by id.
 * 
 * @since 0.7.7.1 12/May/2000
 * @author James Macgill JM
 */
public class IDComparator implements Comparator
{
    /**
     * Compares the id values of the two objects.<br>
     * Both objects must implement the IDReferenced interface otherwise a ClassCastException will be thrown<p>
     * 
     * @author James Macgill JM
     * @since 0.7.7.1 12/May/2000
     * @param a The first object to be commpared id, must implement IDReferenced. (Note all classes which extend GeoShape do this)
     * @param b The second object to be compared by id, must implement IDReferenced.
     * @return int The result of the comparason, -ve if a has a lower id than b +ve if b has a lower id than a.  
     * A value of 0 indecates that both have the same ID.
     * N.B. This does not imply equality, simply that both features share the same ID value.
     */
    public int compare(Object a,Object b){
    
        return ((IDReferenced)a).getID()-((IDReferenced)b).getID();
    }
}

⌨️ 快捷键说明

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