freitemcounter.h
来自「C++编写的代码」· C头文件 代码 · 共 47 行
H
47 行
#ifndef FREQUENT_ITEM_COUNTER_H
#define FREQUENT_ITEM_COUNTER_H
#include <vector>
template <typename ItemType>
struct FrequentItem
{
typedef typename ItemType rawItemTp;
ItemType item_;
unsigned count_;
unsigned SId_;
explicit FrequentItem(const ItemType& item, unsigned count)
{
item_ = item;
count_ = count;
SId_ = 0;
}
};
/*
template <typename ItemType>
inline bool operator<(const FrequentItem<ItemType>& freItem1, const FrequentItem<ItemType>& freItem2)
{
return freItem1.item_.subscript_ < freItem1.item_.subscript_;
}
*/
template <typename FreItemType>
class FreItemCounter
{
typedef typename FreItemType::rawItemTp ItemType;
public:
void Init(unsigned itemSize);
void ResetCounter(); //重新设置计数器,将所有的计数清0。
void CountItem(const ItemType& item, unsigned SId);
void GetFreItems(std::vector<FreItemType>& freItemVec, unsigned minSupport);
protected:
private:
std::vector<FreItemType> itemCountVec_;
};
#include "FreItemCounter.inl"
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?