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

support_counter/SupportCounterLookupEdge.hpp

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

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