📄 prefixspantemplatealgm.h
字号:
#ifndef PREFIX_SPAN_TEMPLATE_ALGORITHM_H
#define PREFIX_SPAN_TEMPLATE_ALGORITHM_H
#include "SQLServerTblWrappers.h"
#include "FreItemCounter.h"
#include "ProjectDB.h"
#include <fstream>
using namespace std;
template<typename PSSequence, typename FreItemTp>
class PSAlgorithm
{
typedef unsigned char CurrentLeverType;
typedef typename FreItemTp::rawItemTp ItemType;
struct ItemNum
{
unsigned int SId_;
unsigned int count_;
ItemNum()
{
SId_ = 0;
count_ = 0;
}
};
public:
~PSAlgorithm()
{
out.close();
dbHandler_.DisconnectDB();
}
bool Init(unsigned long minSupport, unsigned long itemSetSize, string filename);
void prefixSpan();
void doPrefixSpan(PSSequence& prefixSeq, unsigned frequence, std::vector<ProjectedSeqInfo>& projectedDB);
void CountFreItems(const PSSequence& prefixSeq,
const std::vector<ProjectedSeqInfo>& projectedDB,
std::vector<FreItemTp>& SExternFreItemVec,
std::vector<FreItemTp>& IExternFreItemVec);
unsigned GetTotalPatternNum()
{
return totalPatternNum_;
}
protected:
bool GetAllSeqs();
void CountItem(const PSSequence& seq, int currentSId);
void RemoveUnFreItems();
void WriteIntoFSeqsTbl(const PSSequence& seqPattern, unsigned int count);
//如果找到一个合法的扩展,则返回true,反之则返回false。
//该返回值在设置canSeqsVec_和relatedSeqsNum的时候用于判断是否需要修改这两个变量?
bool LastElementExit(const PSSequence& prefixSeq, unsigned index, unsigned pos)const;
//判断sequenceDB_[index]对prefixSeq的投影其pos项的同一element内是否存在prefixSeq的最后一个element
bool CountValidSuffixItem(const PSSequence& prefixSeq,
unsigned index,
const unsigned suffixPos);
private:
unsigned long minSupport_;
std::vector<ItemNum> itemNumVec_;
SQLServerTblWrappers dbHandler_;
std::vector<PSSequence> sequenceDB_;
FreItemCounter<FreItemTp> SExternFreItemCounter_;
FreItemCounter<FreItemTp> IExternFreItemCounter_;
ProjectDB projectedDBInfo_;
unsigned totalPatternNum_;
string filename_;
ofstream out;
};
#include "PrefixSpanTemplateAlgm.inl"
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -