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

📄 itemsetseqlist.java

📁 一个数据挖掘软件ALPHAMINERR的整个过程的JAVA版源代码
💻 JAVA
字号:
/*
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program 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 General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/**
 * Title:        prudsys basket analysis
 * Description:  Basket analysis algorithms
 * Copyright:    Copyright (c) 2001
 * Company:      PRUDENTIAL SYSTEMS SOFTWARE GmbH
 * @author Michael Thess
 * @version 1.0
 */

package com.prudsys.pdm.Models.Sequential.Algorithms.SeqSimple;

import java.util.Vector;

import com.prudsys.pdm.Models.Sequential.ItemSetSeq;

/**
 * List of sequential itemsets.
 *
 * @author Stefan Ludwig
 * @author Michael Thess
 * @version 1.1, 2001/04/19
 */
public class ItemSetSeqList {

  /**
   * Contains sequential itemsets.
   */
  private Vector itemsetseq;

  /**
   * Empty list of sequential itemsets.
   */
  public ItemSetSeqList() {

    itemsetseq = new Vector();
  }

  /**
   * Returns number of sequential itemsets of list.
   *
   * @return number of itemsets
   */
  public int getSize() {

    return itemsetseq.size();
  }

  /**
   * Returns sequential itemsets as vector.
   *
   * @return itemsets
   */
  public Vector getItemSetSeqVector() {
    return itemsetseq;
  }

  /**
   * Returns position of sequential itemset in the list.
   *
   * @param iss sequential itemset
   * @return position of the itemset in the list, -1 if not found
   */
  public int indexOf(ItemSetSeq iss) {

    for (int i = 0; i < getSize(); i++) {
      if ( ((ItemSetSeq)itemsetseq.elementAt(i)).equals(iss) )
        return i;
    };

    return -1;
  }

  /**
   * Does list contain the specified sequential itemset?
   *
   * @param iss sequential item set
   * @return true if itemset contained in list, else false
   */
  public boolean contains(ItemSetSeq iss) {

    return (this.indexOf(iss)>=0);
  }

  /**
   * Gets support count of sequential itemset.
   *
   * @param iss sequential itemset
   * @return support count, -1 if itemset not found in list
   */
  public int getSupportCount(ItemSetSeq iss) {

    for (int i = 0; i < getSize(); i++) {
      if ( iss.equals((ItemSetSeq)itemsetseq.elementAt(i)) )
        return ((ItemSetSeq)itemsetseq.elementAt(i)).getSupportCount();
    };

    return -1;
  }

  /**
   * Copy this list to a new one.
   *
   * @return copy of sequential itemset list
   */
  public ItemSetSeqList copy() {

    ItemSetSeqList newlist = new ItemSetSeqList();

    for(int i = 0; i < getSize(); i++)
      newlist.itemsetseq.addElement(getItemSetSeqAt(i));

    return newlist;
  }

  /**
   * Gets sequential itemset at specified index.
   *
   * @param index position of sequential itemset in list
   * @return sequential itemset, null if not found
   */
  public ItemSetSeq getItemSetSeqAt(int index) {

    if (getSize() <= index) {
      System.out.println("want " + index + " have " + getSize());
      return null;
    };

    return  ((ItemSetSeq)(itemsetseq.elementAt(index)));
  }

  /**
   * Gets sequential itemset at specified index.
   *
   * @param index position of sequential itemset
   * @return sequential itemset at specified position
   */
  public ItemSetSeq getItemSetAtNew(int index) {

    return getItemSetSeqAt(index);
  }

  /**
   * Add new sequential itemset to list no matter whether
   * the element is already contained or not.
   *
   * @param iss new sequential itemset
   */
  public void addItemSetSeq(ItemSetSeq iss) {

    itemsetseq.addElement(iss);
  }

  /**
   * Set sequential itemset at specified index position.
   *
   * @param iss sequential itemset to be set
   * @param index position of sequential itemset to be set
   */
  public void setItemSetSeqAt(ItemSetSeq iss, int index) {

    itemsetseq.setElementAt(iss, index);
  }

  /**
   * Insert sequential itemset into specified index position.
   *
   * @param iss sequential itemset to be inserted
   * @param index position of sequential itemset to be inserted
   */
  public void insertItemSetSeqAt(ItemSetSeq iss, int index) {

    itemsetseq.insertElementAt(iss, index);
  }

  /**
   * Remove sequential itemset at specified index position.
   *
   * @param index position of sequential itemset to be removed
   */
  public void removeItemSetSeqAt(int index) {

    itemsetseq.removeElementAt(index);
  }

  /**
   * String representation of sequential list.
   *
   * @return String representation
   */
  public String toString() {

    String text = "ItemSetSeqList   (" + getSize() + " ItemSetSeqs)" + "\n";
    for (int i = 0; i < getSize(); i++) {
      text = text + "["+i+"]\t" + ((ItemSetSeq)itemsetseq.elementAt(i)).toString();
      text = text + "\n";
    };
    text = text + "---end of ItemSetSeqList---";

    return text;
  }

  /**
   * Print list of sequential itemsets.
   */
  public void print() {

    System.out.println(toString());
  }

}

⌨️ 快捷键说明

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