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

SupportCounterLookupSeq.hpp

Go to the documentation of this file.
00001 
00015 #ifndef SupportCounterLookupSeq_HPP
00016 #define SupportCounterLookupSeq_HPP
00017 
00018 
00019 
00020 #include "common.hpp"
00021 #include <vector>
00022 #include "apriori/bodon/Leaf.hpp"
00023 //#include <cstdio>
00024 //#include <iterator>   //for test
00025 
00026 
00027 
00028 
00029 namespace Bodon
00030 {
00031 namespace sequence
00032 {
00033    template <class TRIE>
00034    class SupportCounterLookupSeq
00035    {
00036       protected:
00037          typedef Leaf LEAF;
00038       public:
00039          SupportCounterLookupSeq( ){}
00040          void updateCounters(
00041             TRIE& main_trie, const std::vector<item_t>& transaction,
00042             item_t candidate_size, const counter_t counter_incr)
00043          {
00044             findCandidates( 
00045                &main_trie, transaction.end()-candidate_size+1, 
00046                transaction.begin(), candidate_size,
00047                counter_incr );
00048          }
00049 
00050       protected:
00053          void findCandidates( TRIE* subtrie,
00054             std::vector<item_t>::const_iterator it_transaction_upper_bound,
00055             std::vector<item_t>::const_iterator it_transaction, 
00056             item_t step_to_candidate,
00057             const counter_t counter_incr );
00058    };
00059 
00060    template <class TRIE> void 
00061    SupportCounterLookupSeq<TRIE>::findCandidates( 
00062       TRIE* subtrie, std::vector<item_t>::const_iterator it_transaction_upper_bound,
00063       std::vector<item_t>::const_iterator it_transaction, 
00064       item_t step_to_candidate, const counter_t counter_incr )
00065    {
00066       std::vector<item_t>::const_iterator it_transaction2;
00067       --step_to_candidate;
00068       if( step_to_candidate ) 
00069       {
00070          for( typename TRIE::iterator it_edge(subtrie->edgelist.begin()); 
00071               it_edge != subtrie->edgelist.end(); ++it_edge)
00072          {
00073             for( it_transaction2 = it_transaction; 
00074                  it_transaction2 != it_transaction_upper_bound;
00075                  ++it_transaction2 )
00076                if(*it_transaction2 == (*it_edge).first )
00077                {
00078                   findCandidates( static_cast<TRIE*>((*it_edge).second),
00079                                   it_transaction_upper_bound + 1, it_transaction2+1, 
00080                                   step_to_candidate, counter_incr);
00081                   break;
00082                }
00083          }
00084       }
00085       else
00086       {
00087          for( typename TRIE::iterator it_edge(subtrie->edgelist.begin()); 
00088               it_edge != subtrie->edgelist.end(); ++it_edge)
00089          {
00090             for( it_transaction2 = it_transaction; 
00091                  it_transaction2 != it_transaction_upper_bound;
00092                  ++it_transaction2 )
00093                if(*it_transaction2 == (*it_edge).first )
00094                {
00095                   static_cast<LEAF*>((*it_edge).second)->increaseCounter( counter_incr);
00096                   break;
00097                }
00098          }
00099       }
00100    }
00101 }
00102 }
00103 #endif

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