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

SupportCounterLookupTrans.hpp

Go to the documentation of this file.
00001 #ifndef SupportCounterLookupTrans_HPP
00002 #define SupportCounterLookupTrans_HPP
00003 
00004 #include "common.hpp"
00005 #include <vector>
00006 #include "apriori/bodon/Leaf.hpp"
00007 //#include <iterator>   //for test
00008 
00009 
00010 
00011 
00012 namespace Bodon
00013 {
00014    template <class TRIE>
00015    class SupportCounterLookupTrans
00016    {
00017       private:
00018          typedef Leaf LEAF;
00019       public:
00020          SupportCounterLookupTrans( ){}
00021          
00022          void updateCounters(
00023             TRIE& main_trie, const std::vector<item_t>& transaction,
00024             item_t candidate_size, const counter_t counter_incr)
00025          {
00026             if( candidate_size <= transaction.size() )
00027                findCandidates( 
00028                   &main_trie, transaction.end()-candidate_size+1, 
00029                   transaction.begin(), candidate_size,
00030                   counter_incr );
00031          }
00032 
00033       protected:
00036          void findCandidates( TRIE* subtrie,
00037             std::vector<item_t>::const_iterator it_basket_upper_bound,
00038             std::vector<item_t>::const_iterator it_basket, 
00039             item_t step_to_candidate,
00040             const counter_t counter_incr );
00041    };
00042 
00043    template <class TRIE> void 
00044    SupportCounterLookupTrans<TRIE>::findCandidates( 
00045       TRIE* subtrie, std::vector<item_t>::const_iterator it_basket_upper_bound,
00046       std::vector<item_t>::const_iterator it_basket, 
00047       item_t step_to_candidate, const counter_t counter_incr )
00048    {
00049       --step_to_candidate;
00050       if( step_to_candidate ) 
00051       {
00052          for( typename TRIE::iterator it_edge(subtrie->edgelist.begin());
00053               it_edge != subtrie->edgelist.end(); ++it_edge)
00054          {
00055             it_basket = std::lower_bound( it_basket, it_basket_upper_bound, 
00056                                           (*it_edge).first);
00057             if(it_basket == it_basket_upper_bound)
00058                break;
00059             else
00060             {
00061                if(*it_basket == (*it_edge).first)
00062                {
00063                   findCandidates( static_cast<TRIE*>((*it_edge).second),
00064                                   it_basket_upper_bound + 1, it_basket, 
00065                                   step_to_candidate, counter_incr);
00066                   ++it_basket;
00067                }
00068             }
00069          }
00070       }
00071       else
00072       {
00073          for( typename TRIE::iterator it_edge(subtrie->edgelist.begin());
00074               it_edge != subtrie->edgelist.end(); ++it_edge)
00075          {
00076             it_basket = std::lower_bound( it_basket, it_basket_upper_bound, 
00077                                           (*it_edge).first);
00078             if(it_basket == it_basket_upper_bound)
00079                break;
00080             else
00081             {
00082                if(*it_basket == (*it_edge).first)
00083                {
00084                   static_cast<LEAF*>((*it_edge).second)
00085                      ->increaseCounter( counter_incr);
00086                   ++it_basket;
00087                }
00088             }
00089          }
00090       }
00091    }
00092 }
00093 #endif

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