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

📄 freitemcounter.h

📁 C++编写的代码
💻 H
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -