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

📄 transaction.java

📁 apriori演算法於JAVA環境下開發 用於資料探勘分類產生規則
💻 JAVA
字号:
/**
 * @(#)Transaction.java
 *
 * Represents a single transaction, containing a set of >=1 items .
 *
 * @author Adrian Bright
 */
import java.util.*;

public class Transaction
{
	private String tID;
	/* A list of item numbers stored in String format */
	private LinkedList items;
	
	/**
     * Transaction Initialises the Transaction.
     */
	public Transaction()
	{
	}

	/**
     * Transaction Initialises the Transaction with a new ID and some items.
	 * @param transID The transaction ID.
	 * @param inputItems The list of items contained in this transaction.
     */
	public Transaction(String transID,LinkedList inputItems) 
	{
		tID = transID;
		items = inputItems;
	}

	/**
     * setTID Sets the transaction ID.
	 * @param id The new transaction ID.
     */
	public void setTID(String id)
	{
		tID = id;
	}

	/**
     * setItems Sets the items included in this transaction, in order.
	 * @param itemsIn The list of items to be added.
     */
	public void setItems(LinkedList itemsIn)
	{
		items = itemsIn;
	}

	/**
     * getTID Returns the ID of this transaction.
	 * @return The transaction ID.
     */
	public String getTID() 
	{
		return tID;
	}

	/**
     * getItems Returns the items of this transaction.
	 * @return The transaction items.
     */
	public LinkedList getItems()
	{
		return items;
	}

	/**
     * isThisSubset Checks if the specified itemset is a subset of this transaction.
	 * @param itemset The itemset to be checked.
	 * @return Whether or not the specified itemset is indeed a subset of the transaction.
     */
	public boolean isThisSubset(LinkedList itemset)
	{
		ListIterator itItemset = itemset.listIterator(0);
		String currentItem;
		int numItemsMatching = 0;
		while (itItemset.hasNext())
		{
			currentItem = (String)itItemset.next();
			if (items.contains(currentItem))
			{
				numItemsMatching++;
			}
		}
		if (numItemsMatching == itemset.size())
		{
			return true;
		}
		else
		{
			return false;
		}
	}

}

⌨️ 快捷键说明

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