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

📄 discreteutility.java

📁 pso源程序
💻 JAVA
字号:
/** * Description: The description of a utility: an AbstractNode with value in Discrete type. * * @ Author        Create/Modi     Note * Xiaofeng Xie    Jan 30, 2004    xiaofengxie@tsinghua.org.cn * * @version 1.0 */package Global.basic.nodes.utilities;import java.util.*;import Global.methods.*;import Global.define.*;public class DiscreteUtility extends StringableUtility {  protected Vector elements = new Vector();  protected DiscreteUtility() {}  protected DiscreteUtility(String outName) {    super(outName);    this.description = "Discrete";  }  public DiscreteUtility(String outName, Vector outElems){    this(outName);    elements = outElems;    if (outElems.size()>0) {      setValue(outElems.elementAt(0));    }  }  public DiscreteUtility(String outName, String[] outElems) {    this(outName, ObjectMatrix.convertArrayTo1DVector(outElems));  }  public DiscreteUtility(String outName, String currentValue, String[] outElems) {    this(outName, outElems);    this.setValue(currentValue);  }  public String getDefaultValue() {    return value.toString();  }  public Object getClonedValue(Object value) {    if(value==null) return null;    return value.toString();  }  public int getElementIndex(Object value){    return StringSearch.getSelectedIndex(getAllElements(), value);  }  public Vector getAllElements(){    return elements;  }  public boolean isSatisfyConstraints(Object data) {    if(!super.isSatisfyConstraints(data)) return false;    int index = getElementIndex(data);    return index!=GlobalValue.INVALID_NATURAL_NUMBER;  }  public Object getRandomElement() {    int index = RandomGenerator.intRangeRandom(0, elements.size()-1);    return elements.get(index).toString();  }}

⌨️ 快捷键说明

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