All Downloads are FREE. Search and download functionalities are using the official Maven repository.

es.ucm.fdi.gaia.jcolibri.method.maintenance.CaseResult Maven / Gradle / Ivy

Go to download

jCOLIBRI is a java framework for the development of Case-Based Reasoning systems.

There is a newer version: 3.2
Show newest version
package es.ucm.fdi.gaia.jcolibri.method.maintenance;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

import es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCase;

/**
 * Stores the case result information. It contains a  pair.
 * The result is some double value related to the case. 
 *
 * @author Lisa Cummins
 */
public class CaseResult extends QueryResult 
{
	/**
	 * Sets up a  pair.
	 * @param _case The case to be stored
	 * @param result The result associated with this case.
	 */
	public CaseResult(CBRCase _case, double result)
	{   super(_case, result);	
	}

	/**
	 * Returns the case.
	 * @return the case.
	 */
	public CBRCase getCase() 
	{	return (CBRCase) _case;
	}

	/**
	 * Sorts the given list of CaseResults in the given order and
	 * returns the sorted list. 
	 * @param ascending The order in which to sort the elements. 
	 * @param toSort The list of CaseResults to sort.
	 * @return the sorted list.
	 */
	public static List sortResults(boolean ascending, List toSort)
	{   Collections.sort(toSort);
	    if(ascending)
	    {	return toSort;	    	    
	    }
	    List sorted = new LinkedList();
	    for(CaseResult res: toSort)
	    {	sorted.add(0, res);	    	    
	    }
	    return sorted;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy