亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? range.java

?? 一個數(shù)據(jù)挖掘系統(tǒng)的源碼
?? JAVA
字號:

/**
 *
 *   AgentAcademy - an open source Data Mining framework for
 *   training intelligent agents
 *
 *   Copyright (C)   2001-2003 AA Consortium.
 *
 *   This library is open source software; you can redistribute it
 *   and/or modify it under the terms of the GNU Lesser General
 *   Public License as published by the Free Software Foundation;
 *   either version 2.0 of the License, or (at your option) any later
 *   version.
 *
 *   This library is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public
 *   License along with this library; if not, write to the Free
 *   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *   MA  02111-1307 USA
 *
 */

package org.agentacademy.modules.dataminer.core;

/**
 * <p>Title: The Data Miner prototype</p>
 * <p>Description: A prototype for the DataMiner (DM), the Agent Academy (AA) module responsible for performing data mining on the contents of the Agent Use Repository (AUR). The extracted knowledge is to be sent back to the AUR in the form of a PMML document.</p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: CERTH</p>
 * @author asymeon
 * @version 0.3
 */

import java.io.*;
import java.util.*;
import org.apache.log4j.Logger;

/**
 * Class representing a range of cardinal numbers. The range is set by a
 * string representation such as: <P>
 *
 * <code>
 *   all
 *   first-last
 *   1,2,3,4
 * </code> <P>
 * or combinations thereof. The range is internally converted from
 * 1-based to 0-based (so methods that set or get numbers not in string
 * format should use 0-based numbers).
 *
 */
public class Range implements Serializable {

  public static Logger                log = Logger.getLogger(Range.class);
  /** Record the string representations of the columns to delete */
  Vector m_RangeStrings = new Vector();

  /** Whether matching should be inverted */
  boolean m_Invert;

  /** The array of flags for whether an column is selected */
  boolean [] m_SelectFlags;

  /** Store the maximum value permitted in the range. -1 indicates that
      no upper value has been set */
  int m_Upper = -1;

  /** Default constructor. */
  public Range() {
  }

  /**
   * Constructor to set initial range.
   *
   * @param rangeList the initial range
   * @exception IllegalArgumentException if the range list is invalid
   */
  public Range(String rangeList) {

    setRanges(rangeList);
  }

  /**
   * Sets the value of "last".
   *
   * @param newUpper the value of "last"
   */
  public void setUpper(int newUpper) {

    if (newUpper >= 0) {
      m_Upper = newUpper;
      setFlags();
    }
  }

  /**
   * Gets whether the range sense is inverted, i.e. all <i>except</i>
   * the values included by the range string are selected.
   *
   * @return whether the matching sense is inverted
   */
  public boolean getInvert() {

    return m_Invert;
  }

  /**
   * Sets whether the range sense is inverted, i.e. all <i>except</i>
   * the values included by the range string are selected.
   *
   * @param newSetting true if the matching sense is inverted
   */
  public void setInvert(boolean newSetting) {

    m_Invert = newSetting;
  }

  /**
   * Gets the string representing the selected range of values
   *
   * @return the range selection string
   */
  public String getRanges() {

    String result = null;
    Enumeration enum = m_RangeStrings.elements();
    while (enum.hasMoreElements()) {
      if (result == null) {
	result = (String)enum.nextElement();
      } else {
	result += ',' + (String)enum.nextElement();
      }
    }
    return (result == null) ? "" : result;
  }

  /**
   * Sets the ranges from a string representation.
   *
   * @param rangeList the comma separated list of ranges. The empty
   * string sets the range to empty.
   * @exception IllegalArgumentException if the rangeList was not well formed
   */
  public void setRanges(String rangeList) {

    Vector ranges = new Vector (10);

    // Split the rangeList up into the vector
    while (!rangeList.equals("")) {
      String range = rangeList.trim();
      int commaLoc = rangeList.indexOf(',');
      if (commaLoc != -1) {
	range = rangeList.substring(0, commaLoc).trim();
	rangeList = rangeList.substring(commaLoc + 1).trim();
      } else {
	rangeList = "";
      }
      if (!range.equals("")) {
	if (isValidRange(range)) {
	  ranges.addElement(range);
	} else {
	  throw new IllegalArgumentException("Invalid range list at " + range
                                             + rangeList);
	}
      }
    }
    m_RangeStrings = ranges;

    if (m_Upper >= 0) {
      setFlags();
    }
  }

  /**
   * Gets whether the supplied cardinal number is included in the current
   * range.
   *
   * @param index the number of interest
   * @return true if index is in the current range
   * @exception RuntimeException if the upper limit of the range hasn't been defined
   */
  public boolean isInRange(int index) {

    if (m_Upper == -1) {
      throw new RuntimeException("No upper limit has been specified for range");
    }
    if (m_Invert) {
      return !m_SelectFlags[index];
    } else {
      return m_SelectFlags[index];
    }
  }

  /**
   * Constructs a representation of the current range. Being a string
   * representation, the numbers are based from 1.
   *
   * @return the string representation of the current range
   */
  public String toString() {

    if (m_RangeStrings.size() == 0) {
      return "Empty";
    }
    String result ="Strings: ";
    Enumeration enum = m_RangeStrings.elements();
    while (enum.hasMoreElements()) {
      result += (String)enum.nextElement() + " ";
    }
    result += "\n";

    result += "Invert: " + m_Invert + "\n";

    try {
      if (m_Upper == -1) {
	throw new RuntimeException("Upper limit has not been specified");
      }
      String cols = null;
      for (int i = 0; i < m_SelectFlags.length; i++) {
	if (isInRange(i)) {
	  if (cols == null) {
	    cols = "Cols: " + (i + 1);
	  } else {
	    cols += "," + (i + 1);
	  }
	}
      }
      if (cols != null) {
	result += cols + "\n";
      }
    } catch (Exception ex) {
      result += ex.getMessage();
    }
    return result;
  }

  /**
   * Gets an array containing all the selected values, in the order
   * that they were selected (or ascending order if range inversion is on)
   *
   * @return the array of selected values
   * @exception RuntimeException if the upper limit of the range hasn't been defined
   */
  public int [] getSelection() {

    if (m_Upper == -1) {
      throw new RuntimeException("No upper limit has been specified for range");
    }
    int [] selectIndices = new int [m_Upper + 1];
    int numSelected = 0;
    if (m_Invert)
    {
      for (int i = 0; i <= m_Upper; i++) {
	if (!m_SelectFlags[i]) {
	  selectIndices[numSelected++] = i;
	}
      }
    }
    else
    {
      Enumeration enum = m_RangeStrings.elements();
      while (enum.hasMoreElements()) {
	String currentRange = (String)enum.nextElement();
	int start = rangeLower(currentRange);
	int end = rangeUpper(currentRange);
	for (int i = start; (i <= m_Upper) && (i <= end); i++) {
	  if (m_SelectFlags[i]) {
	    selectIndices[numSelected++] = i;
	  }
	}
      }
    }
    int [] result = new int [numSelected];
    System.arraycopy(selectIndices, 0, result, 0, numSelected);
    return result;
  }

  /**
   * Creates a string representation of the indices in the supplied array.
   *
   * @param indices an array containing indices to select.
   * Since the array will typically come from a program, indices are assumed
   * from 0, and thus will have 1 added in the String representation.
   */
  public static String indicesToRangeList(int []indices) {

    StringBuffer rl = new StringBuffer();
    int last = -2;
    boolean range = false;
    for(int i = 0; i < indices.length; i++) {
      if (i == 0) {
	rl.append(indices[i] + 1);
      } else if (indices[i] == last) {
        range = true;
      } else {
        if (range) {
          rl.append('-').append(last);
          range = false;
        }
	rl.append(',').append(indices[i] + 1);
      }
      last = indices[i] + 1;
    }
    if (range) {
      rl.append('-').append(last);
    }
    return rl.toString();
  }

  /** Sets the flags array. */
  protected void setFlags() {

    m_SelectFlags = new boolean [m_Upper + 1];
    Enumeration enum = m_RangeStrings.elements();
    while (enum.hasMoreElements()) {
      String currentRange = (String)enum.nextElement();
      int start = rangeLower(currentRange);
      int end = rangeUpper(currentRange);
      for (int i = start; (i <= m_Upper) && (i <= end); i++) {
	m_SelectFlags[i] = true;
      }
    }
  }


  /**
   * Translates a single string selection into it's internal 0-based equivalent
   *
   * @param single the string representing the selection (eg: 1 first last)
   * @return the number corresponding to the selected value
   */
  protected int rangeSingle(String single) {

    if (single.toLowerCase().equals("first")) {
      return 0;
    }
    if (single.toLowerCase().equals("last")) {
      return m_Upper;
    }
    int index = Integer.parseInt(single) - 1;
    if (index < 0) {
      index = 0;
    }
    if (index > m_Upper) {
      index = m_Upper;
    }
    return index;
  }

  /**
   * Translates a range into it's lower index.
   *
   * @param range the string representation of the range
   * @return the lower index of the range
   */
  protected int rangeLower(String range) {

    int hyphenIndex;
    if ((hyphenIndex = range.indexOf('-')) >= 0) {
      return Math.min(rangeLower(range.substring(0, hyphenIndex)),
		       rangeLower(range.substring(hyphenIndex + 1)));
    }
    return rangeSingle(range);
  }

  /**
   * Translates a range into it's upper index. Must only be called once
   * setUpper has been called.
   *
   * @param range the string representation of the range
   * @return the upper index of the range
   */
  protected int rangeUpper(String range) {

    int hyphenIndex;
    if ((hyphenIndex = range.indexOf('-')) >= 0) {
      return Math.max(rangeUpper(range.substring(0, hyphenIndex)),
		       rangeUpper(range.substring(hyphenIndex + 1)));
    }
    return rangeSingle(range);
  }

  /**
   * Determines if a string represents a valid index or simple range.
   * Examples: <code>first  last   2   first-last  first-4  4-last</code>
   * Doesn't check that a < b for a-b
   *
   * @param range
   * @return true if the range is valid
   */
  protected boolean isValidRange(String range) {

    if (range == null) {
      return false;
    }
    int hyphenIndex;
    if ((hyphenIndex = range.indexOf('-')) >= 0) {
      if (isValidRange(range.substring(0, hyphenIndex)) &&
	  isValidRange(range.substring(hyphenIndex + 1))) {
	return true;
      }
      return false;
    }
    if (range.toLowerCase().equals("first")) {
      return true;
    }
    if (range.toLowerCase().equals("last")) {
      return true;
    }
    try {
      int index = Integer.parseInt(range);
      if (index > 0) {
	return true;
      }
      return false;
    } catch (NumberFormatException ex) {
      return false;
    }
  }

  /**
   * Main method for testing this class.
   *
   * @param argv one parameter: a test range specification
   */
  public static void main(String [] argv) {

    try {
      if (argv.length == 0) {
	throw new Exception("Usage: Range <rangespec>");
      }
      Range range = new Range();
      range.setRanges(argv[0]);
      range.setUpper(9);
      range.setInvert(false);
      System.out.println("Input: " + argv[0] + "\n"
			 + range.toString());
      int [] rangeIndices = range.getSelection();
      for (int i = 0; i < rangeIndices.length; i++)
	System.out.print(" " + (rangeIndices[i] + 1));
      System.out.println("");
    } catch (Exception ex) {
      log.error(ex.getMessage());
    }
  }
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一本久久综合亚洲鲁鲁五月天| 成人av网址在线| 日本一区二区三区免费乱视频 | 欧美va亚洲va| 激情综合色播激情啊| 亚洲成人1区2区| 国产拍揄自揄精品视频麻豆| 91精品国产欧美一区二区| 欧美日本国产一区| 欧美美女一区二区三区| 色婷婷精品大在线视频| 99国产精品一区| 成人99免费视频| jizzjizzjizz欧美| 成人精品在线视频观看| 精品影视av免费| 麻豆国产91在线播放| 麻豆精品久久精品色综合| 日韩国产欧美在线视频| 日韩精品一级中文字幕精品视频免费观看| 一区二区三区四区中文字幕| 亚洲柠檬福利资源导航| 亚洲精品中文字幕乱码三区| 一区二区三区不卡视频| 亚洲一区二区精品久久av| 久久精品国产精品亚洲精品| 久久av老司机精品网站导航| 国内精品国产成人国产三级粉色 | 精品久久久久久久久久久院品网 | 日韩和的一区二区| 日韩主播视频在线| 蜜臀av性久久久久蜜臀aⅴ四虎| 免费高清不卡av| 精品影视av免费| gogogo免费视频观看亚洲一| 色综合激情久久| 欧美最猛黑人xxxxx猛交| 欧美另类z0zxhd电影| 日韩一级免费观看| 国产欧美日本一区视频| 一区二区在线免费| 捆绑调教一区二区三区| 欧美日韩在线播放三区四区| 日韩午夜av电影| 中文乱码免费一区二区| 亚洲地区一二三色| 国产丶欧美丶日本不卡视频| 色婷婷久久久亚洲一区二区三区 | 韩国中文字幕2020精品| 国产成人av电影免费在线观看| 91丝袜呻吟高潮美腿白嫩在线观看| 在线精品国精品国产尤物884a| 91.com在线观看| 欧美精彩视频一区二区三区| 亚洲综合在线电影| 激情五月播播久久久精品| www.av精品| 日韩精品一区二区三区在线播放| 日韩毛片视频在线看| 免费观看久久久4p| 国产激情91久久精品导航 | 日韩av不卡一区二区| 久久不见久久见免费视频7| 91视频你懂的| 欧美大度的电影原声| 亚洲欧美一区二区三区国产精品| 九九九久久久精品| 欧美视频在线观看一区二区| 日本一区二区三区在线观看| 蜜桃视频第一区免费观看| 色综合视频一区二区三区高清| 久久综合给合久久狠狠狠97色69| 亚洲一区在线免费观看| 国产成人av电影在线播放| 日韩一区二区三区视频| 亚洲影视在线观看| 99国产精品久久久久久久久久 | 欧美一区二区私人影院日本| 亚洲欧美视频在线观看视频| 成人性生交大片免费看在线播放 | 欧美在线高清视频| 中文字幕日韩精品一区| 国产一区二区在线看| 欧美一区二区三区公司| 亚洲v中文字幕| 欧美亚洲日本国产| 悠悠色在线精品| 91国偷自产一区二区三区观看 | 亚洲女性喷水在线观看一区| 国产激情视频一区二区三区欧美| 精品少妇一区二区| 日本欧美一区二区在线观看| 欧美裸体一区二区三区| 午夜国产不卡在线观看视频| 欧美三级视频在线| 亚洲成av人**亚洲成av**| 欧美优质美女网站| 一区二区高清免费观看影视大全| 国产精品一级片| 久久免费精品国产久精品久久久久| 精品一区二区三区视频在线观看| 欧美日韩日日摸| 一区二区免费看| 欧美性欧美巨大黑白大战| 奇米精品一区二区三区在线观看| 色天使色偷偷av一区二区| 亚洲精品国产成人久久av盗摄 | 欧美日韩国产一级片| 亚洲福利一区二区三区| 91精品婷婷国产综合久久| 美国十次综合导航| 亚洲国产经典视频| 色国产综合视频| 美国毛片一区二区三区| 中文无字幕一区二区三区| 一本色道久久综合狠狠躁的推荐| 亚洲成av人片| 国产视频在线观看一区二区三区| 色综合婷婷久久| 日韩电影一二三区| 国产清纯美女被跳蛋高潮一区二区久久w | 国产sm精品调教视频网站| 国产精品国产三级国产普通话三级 | 在线观看成人小视频| 亚洲午夜久久久久| 久久亚洲精品小早川怜子| 91小视频免费看| 日韩av电影一区| 久久一区二区三区国产精品| 国产.欧美.日韩| 天天操天天色综合| 国产精品久久久久久久久久免费看 | 卡一卡二国产精品| 国产人久久人人人人爽| 在线亚洲免费视频| 国产精品18久久久久久久久久久久| 亚洲免费观看高清完整版在线观看| 7777精品伊人久久久大香线蕉经典版下载 | 国产精品嫩草99a| 在线观看91av| 色综合久久中文综合久久牛| 精品一区二区在线视频| 亚洲高清免费视频| 综合分类小说区另类春色亚洲小说欧美 | 日本视频免费一区| 亚洲人成精品久久久久久| 2欧美一区二区三区在线观看视频| 一本久道久久综合中文字幕| 国产高清亚洲一区| 韩国成人福利片在线播放| 亚洲一级不卡视频| 亚洲免费观看在线视频| 日本一区二区在线不卡| 久久久一区二区三区| 欧美一区二区福利在线| 欧洲视频一区二区| 99re成人精品视频| 成人av在线观| 国产福利精品导航| 国内精品写真在线观看| 另类成人小视频在线| 秋霞影院一区二区| 日韩成人免费电影| 无码av免费一区二区三区试看 | 成人综合婷婷国产精品久久| 美女视频免费一区| 久久精品国产网站| 蜜桃av一区二区在线观看| 麻豆精品一区二区三区| 日本色综合中文字幕| 青草国产精品久久久久久| 免费久久精品视频| 国产成人无遮挡在线视频| aa级大片欧美| 91精品国产一区二区三区| 亚洲精品一区二区三区福利 | 国产欧美一二三区| 亚洲伦在线观看| 日本美女一区二区三区视频| 国产精品1024| 欧美日韩精品二区第二页| 精品成人私密视频| 一区二区三区在线免费视频| 免费观看91视频大全| 91美女在线看| 日韩一区二区三区在线观看| 中文字幕人成不卡一区| 天天av天天翘天天综合网色鬼国产| 国内精品不卡在线| 色综合久久中文综合久久97| 精品久久久久久久人人人人传媒| 亚洲欧美在线视频观看| 精品一区二区国语对白| 欧洲另类一二三四区| 中文字幕乱码日本亚洲一区二区 | 亚洲三级视频在线观看| 美日韩一区二区| 欧洲精品视频在线观看| 日本一区二区免费在线| 麻豆成人av在线|