Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

prefixarray/CandidateGeneratorNoprune.hpp

Go to the documentation of this file.
00001 #ifndef CandidateGeneratorNoprune_prefix_HPP
00002 #define CandidateGeneratorNoprune_prefix_HPP
00003 
00004 #include "datastructures/PrefixArrayList.hpp"
00005 #include "apriori/bodon-vector/CandidateGeneratorNoprune.hpp"
00006 #include "common/log.h"
00007 //#include <cstdio>
00008 //#include <iterator>   //for test
00009 
00010 
00011 
00012 
00013 namespace Bodon
00014 {
00015 namespace prefix_array
00016 {
00017    template <class DATASTRUCTURE, class D, class DUMMY>
00018    class CandidateGeneratorNoprune 
00019    {
00020       protected:
00021          DATASTRUCTURE& candidates; 
00022          D& decoder;
00023          DUMMY& dummy; 
00024          bool newCandidate;
00025       public:
00026          CandidateGeneratorNoprune<DATASTRUCTURE, D, DUMMY> 
00027          (DATASTRUCTURE& candidates, D& decoder, DUMMY& dummy) :
00028             candidates(candidates), decoder(decoder), dummy(dummy){}
00029 
00030 
00036          void generateCandidate(unsigned int candidate_size);
00037       
00038          void afterWorkCandGen(){}
00039 
00040          bool isThereAnyCandidate()
00041          {
00042             return newCandidate;
00043          }
00044       protected:
00045          void generateCandidateSizeThree();
00046    };
00047 
00048 
00049    template <class DATASTRUCTURE, class D, class DUMMY> inline
00050    void CandidateGeneratorNoprune<DATASTRUCTURE, D, DUMMY>::
00051    generateCandidate(const unsigned int candidate_size)
00052    {
00053       newCandidate = false;
00054       if(candidate_size == 3)
00055          generateCandidateSizeThree();
00056       else
00057       {
00058          for( typename DATASTRUCTURE::iterator it1 = candidates.begin();
00059               it1 != candidates.end(); ++it1)
00060             for(diag_array_row_t::iterator it2 = (*it1).begin();it2 != (*it1).end(); ++it2)
00061             {
00062                Bodon::vector_based::CandidateGeneratorNoprune<D, DUMMY> 
00063                   cand_gen(*it2, decoder, dummy);
00064                cand_gen.generateCandidate(candidate_size);
00065                if(!(*it2).empty())
00066                   newCandidate = true;
00067             }
00068       }
00069    }
00070 
00071    template <class DATASTRUCTURE, class D, class DUMMY> inline
00072    void CandidateGeneratorNoprune<DATASTRUCTURE, D, DUMMY>::
00073    generateCandidateSizeThree()
00074    {
00075       itemvector new_candidate;
00076       for(typename DATASTRUCTURE::size_type index1 = 0; 
00077           index1 != candidates.size(); ++index1)
00078          for(diag_array_row_t::size_type index2
00079                 = 0;index2 < candidates[index1].size(); ++index2)
00080          {
00081             if(!candidates[index1][index2].empty())
00082             {
00083                candidates[index1][index2].pop_back();
00084                for(diag_array_row_t::size_type index3
00085                       = index2 + 1; index3 < candidates[index1].size(); ++index3)
00086                   if(!candidates[index1][index3].empty())
00087                   {
00088                      new_candidate.push_back(index3 + index1 + 1);
00089                      candidates[index1][index2].push_back(itemvecCounterPair(new_candidate, 0));
00090                      newCandidate = true;
00091                      new_candidate.pop_back();         
00092                   }
00093             }
00094          }
00095    }
00096 }
00097 }
00098 #endif
00099 

Generated on Sun Sep 17 17:50:38 2006 for FIM environment by  doxygen 1.4.4