00001 #ifndef InfrequentRemover_prefix_HPP
00002 #define InfrequentRemover_prefix_HPP
00003
00004 #include "apriori/bodon-vector/vector_typedef.hpp"
00005 #include "common/log.h"
00006
00007
00008
00009
00010
00011
00012 namespace Bodon
00013 {
00014 namespace prefix_array
00015 {
00016 template <class DATASTRUCTURE,class D, class DUMMY>
00017 class InfrequentRemover
00018 {
00019 protected:
00020 DATASTRUCTURE& candidates;
00021 D& decoder;
00022 DUMMY& dummy;
00023 public:
00024 InfrequentRemover<DATASTRUCTURE, D, DUMMY>
00025 (DATASTRUCTURE& candidates, D& decoder, DUMMY& dummy) :
00026 candidates(candidates), decoder(decoder),
00027 dummy(dummy){}
00028
00029
00030 void deleteInfrequent( const counter_t min_supp,
00031 const unsigned int candidate_size );
00032 void afterWorkDel(){}
00033 protected:
00034
00035
00036 };
00041 template <class DATASTRUCTURE, class D, class DUMMY> inline
00042 void InfrequentRemover<DATASTRUCTURE, D, DUMMY>::
00043 deleteInfrequent( const counter_t min_supp,
00044 const unsigned int candidate_size )
00045 {
00046 for( typename DATASTRUCTURE::size_type index1 = 0;
00047 index1 != candidates.size(); ++index1)
00048 for( diag_array_row_t::size_type index2 = 0;
00049 index2 != candidates[index1].size(); ++index2)
00050 {
00051 cand_vector_t::iterator it = candidates[index1][index2].begin();
00052 while(it != candidates[index1][index2].end())
00053 if((*it).second < min_supp)
00054 it = candidates[index1][index2].erase(it);
00055 else
00056 {
00057 (*it).first.push_back(index1);
00058 (*it).first.push_back(index2 + index1 + 1);
00059 decoder.writeItemsetAndCounter(
00060 (*it).first.begin(), (*it).first.end(), (*it).second);
00061 (*it).first.pop_back();
00062 (*it).first.pop_back();
00063 ++it;
00064 }
00065 }
00066 }
00067
00068 }
00069 }
00070 #endif