00001 #ifndef CandidateGeneratorNoprune_HPP
00002 #define CandidateGeneratorNoprune_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 vector_based
00015 {
00016 template <class D, class DUMMY>
00017 class CandidateGeneratorNoprune
00018 {
00019 protected:
00020 cand_vector_t& candidates;
00021 public:
00022 CandidateGeneratorNoprune<D, DUMMY>
00023 ( cand_vector_t& candidates, D& decoder, DUMMY& dummy) :
00024 candidates(candidates){}
00025
00026
00032 void generateCandidate(unsigned int candidate_size);
00033
00034 void afterWorkCandGen(){}
00035
00036 bool isThereAnyCandidate()
00037 {
00038 return !candidates.empty();
00039 }
00040 };
00041
00042
00043 template <class D, class DUMMY> inline
00044 void CandidateGeneratorNoprune<D, DUMMY>::
00045 generateCandidate(const unsigned int candidate_size)
00046 {
00047 if(!candidates.empty())
00048 {
00049 cand_vector_t::size_type orig_size(candidates.size());
00050 itemvector new_candidate;
00051 cand_vector_t::size_type index=0, index2;
00052 for(;index < orig_size -1; ++index)
00053 {
00054 new_candidate.clear();
00055 new_candidate.insert(new_candidate.end(),
00056 candidates[index].first.begin(),
00057 candidates[index].first.end());
00058 index2 = index +1;
00059 while(index2 < orig_size &&
00060 candidates[index].first.haveSamePrefix(candidates[index2].first))
00061 {
00062 new_candidate.push_back(candidates[index2].first.back());
00063 candidates.push_back(
00064 itemvecCounterPair(new_candidate, 0));
00065 new_candidate.pop_back();
00066 ++index2;
00067 }
00068 }
00069 candidates.erase(candidates.begin(), candidates.begin()+orig_size);
00070 }
00071 }
00072 }
00073 }
00074 #endif