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

📄 itemsetlist.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 Stefan Ludwig
 * @author Michael Thess
 * @version 1.0
 */
package com.prudsys.pdm.Models.Sequential.Algorithms.SeqSimple;

import java.util.Vector;

import com.prudsys.pdm.Models.AssociationRules.ItemSet;
import com.prudsys.pdm.Utils.IntVector;

/**
 * Handling of list of itemsets.
 *
 * @author Stefan Ludwig
 * @author Michael Thess
 * @version 2.0, 2001/04/21
 */
public class ItemSetList {

  /**
   * Empty list of itemsets
   */
  public ItemSetList() {itemset=new Vector(); }

  public Vector itemset; //contains ItemSets
  IntVector index=null;

  public int indexOf(ItemSet is) {
    for (int i=0; i<itemset.size(); i++)
       { if (((ItemSet)itemset.elementAt(i)).equals(is)) return i; }
    return -1;
  }

  public int getSize() {return itemset.size(); }


  public ItemSet getItemSetAt(int index) {
    if (itemset.size()<=index)
    { System.out.println("want "+index+" have "+itemset.size()); return null;}
    return  ((ItemSet)(itemset.elementAt(index))); }

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

    return getItemSetAt(index);
  }

  public int getIntegerAt(int setindex, int elementindex) {
    if (this.getSize()-1<setindex) return -1;
    if (this.getItemSetAt(setindex).getSize()-1< elementindex) return -1;
        return this.getItemSetAt(setindex).getItemAt(elementindex);
  }

  public int getSupportCount(ItemSet is) {
    int from=index.IntegerAt(is.getSize());
    int to=index.IntegerAt(is.getSize()+1);
   for (int i=from;i<to;i++)
   {
    if (is.equals((ItemSet)itemset.elementAt(i)))
      return ((ItemSet)itemset.elementAt(i)).getSupportCount();
   }
   return -1;
  }

  public boolean contains(ItemSet is) {return (this.indexOf(is)>=0); }

  public ItemSetList copy() { ItemSetList newlist =new ItemSetList();
                              for(int i=0; i<getSize(); i++)
                                newlist.itemset.addElement(getItemSetAt(i));
                              return newlist;
                            }

  public void addItemSet(ItemSet is) {
    if (!this.contains(is))
      itemset.addElement(is);
  }

  public void insertItemSet(ItemSet is) {
    itemset.addElement(is);
  }

  public void insertItemSetAt(ItemSet is, int index) {
    itemset.insertElementAt(is, index);

  }

  public void delItemSetAt(int  index) {
    itemset.removeElementAt(index);
  }

  public void generateIndex() {
      index=new IntVector();
      index.addElement(-1);
      int length=0;
      for (int i=0; i<itemset.size(); i++)
        if (length< ((ItemSet)itemset.elementAt(i)).getSize()) {length++; index.addElement(i); }
      index.addElement(itemset.size());
    }

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

    String text = "ItemSetList   (" + getSize() + " ItemSets)" + "\n";
    for (int i = 0; i < getSize(); i++) {
      text = text + "["+i+"]\t" + ((ItemSet)itemset.elementAt(i)).toString();
      text = text + "\n";
    };
    text = text + "---end of ItemSetList---";

    return text;
  }

  public void print() {

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

}

⌨️ 快捷键说明

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