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

WeightedSupportCounterLookupSeq.hpp

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

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