00001 #ifndef SupportCounter_HPP
00002 #define SupportCounter_HPP
00003
00004 #include "apriori/bodon-vector/vector_typedef.hpp"
00005
00006
00007
00008
00009
00010
00011 namespace Bodon
00012 {
00013 namespace vector_based
00014 {
00015 template<class DATA_STRUCTURE>
00016 class SupportCounter
00017 {
00018 public:
00019 SupportCounter<DATA_STRUCTURE>() {}
00020
00021 public:
00024 void updateCounters(
00025 DATA_STRUCTURE& candidates, const std::vector<item_t>& transaction,
00026 const unsigned int candidate_size, const counter_t counter_incr );
00027 void updateCounters(
00028 DATA_STRUCTURE& candidates, std::vector<item_t>::const_iterator transaction_beg,
00029 std::vector<item_t>::const_iterator transaction_end,
00030 const unsigned int candidate_size, const counter_t counter_incr );
00031 };
00032
00033 template<class DATA_STRUCTURE> inline
00034 void SupportCounter<DATA_STRUCTURE>::updateCounters(
00035 DATA_STRUCTURE& candidates, const std::vector<item_t>& transaction,
00036 const unsigned int candidate_size, const counter_t counter_incr )
00037 {
00038
00039
00040 updateCounters(
00041 candidates, transaction.begin(),
00042 transaction.end(), candidate_size, counter_incr);
00043
00044 }
00045 template<class DATA_STRUCTURE> inline
00046 void SupportCounter<DATA_STRUCTURE>::updateCounters(
00047 DATA_STRUCTURE& candidates, std::vector<item_t>::const_iterator transaction_beg,
00048 std::vector<item_t>::const_iterator transaction_end,
00049 const unsigned int candidate_size, const counter_t counter_incr )
00050 {
00051 for(typename DATA_STRUCTURE::iterator it = candidates.begin();
00052 it != candidates.end(); ++it)
00053 {
00054 if((*it).first.isContained(transaction_beg, transaction_end ))
00055 (*it).second += counter_incr;
00056 }
00057 }
00058
00059 }
00060 }
00061 #endif