📄 selectdifference.java
字号:
/*--- formatted by Jindent 2.1, (www.c-lab.de/~jindent) ---*//** * SelectDifference Class * * location: net.openai.ai.ga.selection.common.SelectDifference * */package net.openai.ai.ga.selection.common;import net.openai.ai.ga.selection.*;import net.openai.ai.ga.population.*;import net.openai.ai.ga.cell.*;import java.util.Collection;/** * <code>SelectDifference</code> is a <code>SelectionAlgorithm</code> * that will return the difference of the results of two specified <code> * SelectionAlgorithm</code>s. * * @author Jared Grubb * @version %I%, %G% * @since JDK1.3 */public class SelectDifference implements SelectionAlgorithm { private SelectionAlgorithm arg1, arg2; /** * Creates a new <code>SelectDifference</code> object for taking the * difference of the <code>Population</code>s returned by the two * passed <code>SelectionAlgorithm</code>s. * * @param first the first <code>SelectionAlgorithm</code> * @param second the second <code>SelectionAlgorithm</code> */ public SelectDifference(SelectionAlgorithm first, SelectionAlgorithm second) { this.arg1 = first; this.arg2 = second; } /** * Returns a <code>Population</code> that represents the difference * (disjunction) of the two <code>SelectionAlgorithm</code>s specified in * the constructor. The return is the result of the first selection * algorithm with the results of the second removed from it via * <code>Population.removeCells</code> method. * * If the first selection algorithm returns a <code>null</code> then a * <code>NullPointerException</code> will be thrown. If the second one * returns a <code>null</code>, the the results of the first will be * returned unchanged. * * @param pop the <code>Population</code> to choose from * @return the difference <code>Population</code> of the two selection * algorithms */ public Population selectFromPopulation(Population pop) { Population toReturn = arg1.selectFromPopulation(pop); toReturn.removeCells(arg2.selectFromPopulation(pop)); return toReturn; }}/*--- formatting done in "Sun Java Convention" style on 12-28-2000 ---*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -