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

SupportCounterLookupEdgePrevMem.hpp

Go to the documentation of this file.
00001 #ifndef SupportCounterLookupEdgePrevMem_HPP
00002 #define SupportCounterLookupEdgePrevMem_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 SupportCounterLookupEdgePrevMem
00016    {
00017       public:
00018          SupportCounterLookupEdgePrevMem( ){}
00019 
00020          void updateCounters(
00021             TRIE& main_trie, const std::vector<item_t>& transaction,
00022             item_t candidate_size, const counter_t counter_incr)
00023          {
00024             if( candidate_size <= transaction.size() )
00025                findCandidates( 
00026                   &main_trie, transaction.end()-candidate_size+1, 
00027                   transaction.begin(), candidate_size,
00028                   counter_incr );
00029          }
00030 
00031       protected:
00034          void findCandidates( TRIE* subtrie,
00035             std::vector<item_t>::const_iterator it_basket_upper_bound,
00036             std::vector<item_t>::const_iterator it_basket, 
00037             item_t step_to_candidate,
00038             const counter_t counter_incr );
00039    };
00040 
00041    template <class TRIE> void 
00042    SupportCounterLookupEdgePrevMem<TRIE>::findCandidates( 
00043       TRIE* subtrie, std::vector<item_t>::const_iterator it_basket_upper_bound,
00044       std::vector<item_t>::const_iterator it_basket, 
00045       item_t step_to_candidate, const counter_t counter_incr )
00046    {
00047       --step_to_candidate;
00048       typename TRIE::iterator it_edge(subtrie->edgelist.begin());
00049       if( step_to_candidate ) 
00050       {
00051          for( ;it_basket != it_basket_upper_bound; ++it_basket )
00052          {
00053             subtrie->edgelist.lower_bound(it_edge, *it_basket);
00054             if( it_edge == subtrie->edgelist.end() )
00055                break;
00056             else
00057             {
00058                if( (*it_edge).first == *it_basket )
00059                {                  
00060                   findCandidates( static_cast<TRIE*>((*it_edge).second),
00061                                   it_basket_upper_bound + 1, it_basket, 
00062                                   step_to_candidate, counter_incr);
00063                   ++it_edge;
00064                }
00065             }
00066          }
00067       }
00068       else
00069       {
00070          for( ;it_basket != it_basket_upper_bound; ++it_basket )
00071          {
00072             subtrie->edgelist.lower_bound(it_edge, *it_basket);
00073             if( it_edge == subtrie->edgelist.end() )
00074                break;
00075             else
00076             {
00077                if( (*it_edge).first == *it_basket )
00078                {                  
00079                   static_cast<Leaf*>((*it_edge).second)
00080                      ->increaseCounter( counter_incr);
00081                   ++it_edge;
00082                }
00083             }
00084          }
00085       }
00086    }
00087 }
00088 #endif

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