/* $Id: CISortComperator.java 125 2011-03-09 09:49:51Z ohura $ */
package smart_gs.reasoning_web.swingui;

import java.util.Comparator;
import java.util.Hashtable;

import reasoning_web.logical.ResourcePointer;

public class CISortComperator implements Comparator{
	
	Hashtable<ResourcePointer,Double> table;
	
	public CISortComperator(Hashtable<ResourcePointer,Double> table) {
		this.table = table;
	}
	
	public int compare(Object p1, Object p2) {
		
		ResourcePointer pointer1 = (ResourcePointer)p1;
		ResourcePointer pointer2 = (ResourcePointer)p2;
		
		double ci1 = this.table.get(pointer1);
		double ci2 = this.table.get(pointer2);
		
		if(ci1 < ci2){
			return -1;  //１番目の引数の方が大きい場合には負の値を返す
		}else if(ci1 > ci2){
			return 1;  //２番目の引数の方が大きい場合には正の値を返す
		}
		return 0;     //等しい場合はzero
	}
	
	
}
