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

📄 item.java

📁 aprori algorithm, easy to understand and modify
💻 JAVA
字号:
//package datamining;

import java.util.*;

/**
 * Class for implementing a Trie Item.
 *
 * @author	Michael Holler
 */
public class Item {
	
  private int label;
  private int support;

  private Vector children;
  private Vector path;
	
  /**
   * Constructor for creating a Item object.
   * Sets instance variables to default.
   */
  public Item() {
    this.label = 0;
    this.support = 0;
    this.children = new Vector();
    this.path = new Vector();
  }
  
  /**
   * Constructor for creating an Item object.
   * Sets the label given as parameter and the
   * other variables to default.
   *
   * @param	label	the label of the Item
   */
  public Item(int label) {
    this.label = label;
    this.support = 0;
    this.children = new Vector();
    this.path = new Vector();
  }

  /**
   * Sets the instance variable label to the parameter label.
   *
   * @param	label	the new label of the Item
   */ 
  public void setLabel(int label) {
    this.label = label;
  }

  /**
   * Gets the label of the Item.
   *
   * @return		the label of the item
   */
  public int getLabel() {
    return this.label;
  }

  /**
   * Increases the support of the Item by one.
   */
  public void incSupport() {
    this.support++;
  }

  /**
   * Increases the support of the Item by the parameter.
   *
   * @param	add	the amount added to the support
   */
  public void incSupport(int add) {
    this.support += add;
  }

  /**
   * Sets the support of the Item to the support given as parameter.
   *
   * @param	support	the new support of the Item
   */
  public void setSupport(int support) {
    this.support = support;
  }

  /**
   * Gets the support of the Item.
   *
   * @return		the support of the Item
   */
  public int getSupport() {
    return this.support;
  }

  /**
   * Adds a child to the Item. The child is added as the last child.
   *
   * @param	child	the child to be added
   */
  public void addChild(Item child) {
    this.children.addElement(child);
  }

  /**
   * Adds a child to the Item. The child will be added to as
   * the child which is given by the parameter index. All children
   * after index are moved forward.
   *
   * @param	child	the child to be added
   * @param	index	the position where the child will be added
   */
  public void addChild(Item child, int index) {
    this.children.insertElementAt(child, index);
  }

  /**
   * Tells whether this Item has any children.
   *
   * @return		true, if there are children, else false
   */
  public boolean hasChildren() { 
    try {
    if (this.children.firstElement() != null)
      return true;
    else
      return false;
    } catch (Exception e) {
      return false;
    }
  }

  /**
   * Gets the children of this Item.
   *
   * @return 		the children of this Item
   */
  public Vector getChildren() {
    return this.children;
  }

  /**
   * Adds a path to the Item.
   *
   * @param	path	the path to be added
   */
  public void addPath(Vector path) {
    this.path.addAll(path);
  }

  /**
   * Gets the rules for this Item.
   *
   * @return 		the rules for this Item
   */
  public Vector getPath() {
    return this.path;
  }

  /**
   * Tells whether this Item is derivable. This is used when
   * generating derivable itemset from the non-derivables.
   *
   * @return		true, if there are elements in the path, else false
   */
  public boolean isDI() { 
    try {
    if (this.path.firstElement() != null)
      return true;
    else
      return false;
    } catch (Exception e) {
      return false;
    }
  }

  /**
   * Checks if the Item given as parameter has the same label as
   * this one.
   *
   * @return		true, if the label is the same, else false
   */
  public boolean equals(Object item) {
    Item tmp = (Item)item;
    if (tmp.getLabel() == this.label) {
      return true;
    } 
    return false;
  }

}

⌨️ 快捷键说明

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