www.pudn.com > apriori的vc源代码.zip > ItemSet.h


// 
// Class for itemset. 
// 
// 
#ifndef _ITEMSET_H_ 
#define _ITEMSET_H_ 
 
#include "tzObject.h" 
#include  
 
typedef int Item; 
 
 
/* to find the minimum and maximum integer from two parameters */ 
#define imax(a, b) (((a) > (b))?(a):(b)) 
#define imin(a, b) (((a) < (b))?(a):(b)) 
 
 
// Relationship between two ItemSet s 
#define TOTALEQUAL 0 
#define MAKEUP     1 
#define TOTALDIFF  2 
#define CROSS      3 
 
 
 
class itemSet : public tzObject 
{ 
 
public: 
 
    itemSet() 
    { 
        m_items = (Item *)NULL; 
        count = 0; 
        m_support = 0; 
        m_weight = 0.0; 
        m_keeporder = true; 
    }; 
 
    ~itemSet() 
    { 
        delete m_items; 
    }; 
 
 
    void add(Item theitem); 
    void add(int index, Item theitem); 
     
    void concat(itemSet *src); 
    void clear(); 
    tzObject *clone(); 
    int compare(tzObject *obj); 
    Item get(int index); 
    int indexOf(Item theitem, bool ascend = true); 
    Item remove(int index); 
 
    itemSet *left(int nCount); 
 
    itemSet *sub(int bgn, int end); 
    itemSet *substract(itemSet *aset); 
 
   
    void dump(); 
     
    bool keeporder()            { return m_keeporder; }; 
    void keeporder(bool value)  { m_keeporder = value; }; 
     
    int size()                  { return count; }; 
     
    long support()              { return m_support; }; 
    void support(long value)    { m_support = value; }; 
     
    double weight()             { return m_weight; }; 
    void weight(double value)   { m_weight = value; } 
	 
private: 
 
    Item *m_items; 
    int count; 
 
    bool m_keeporder; 
     
    long m_support; 
    double m_weight; 
	 
}; 
 
 
 
#endif