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

sequence/support_counter/SupportCounterLookupEdge.hpp

Go to the documentation of this file.
00001 
00010 #ifndef SupportCounterLookupEdge_HPP
00011 #define SupportCounterLookupEdge_HPP
00012 
00013 
00014 #include "common.hpp"
00015 #include <vector>
00016 #include "apriori/bodon/Leaf.hpp"
00017 
00018 
00019 namespace Bodon
00020 {
00021 namespace sequence
00022 {
00023    template <class TRIE>
00024    class SupportCounterLookupEdge
00025    {
00026       public:
00027          SupportCounterLookupEdge( ){}
00028 
00029          void updateCounters(
00030             TRIE& main_trie, const std::vector<item_t>& transaction,
00031             item_t candidate_size, const counter_t counter_incr)
00032          {
00033             findCandidates( 
00034                &main_trie, transaction.end()-candidate_size+1, 
00035                transaction.begin(), candidate_size,
00036                counter_incr );
00037          }
00038       protected:
00039          typedef Leaf LEAF;
00042          void findCandidates( TRIE* subtrie,
00043             std::vector<item_t>::const_iterator it_transaction_upper_bound,
00044             std::vector<item_t>::const_iterator it_transaction, 
00045             item_t step_to_candidate,
00046             const counter_t counter_incr );
00047 
00048    };
00049 
00050    template <class TRIE> void 
00051    SupportCounterLookupEdge<TRIE>::findCandidates( 
00052       TRIE* subtrie, std::vector<item_t>::const_iterator 
00053       it_transaction_upper_bound,
00054       std::vector<item_t>::const_iterator it_transaction, 
00055       item_t step_to_candidate, const counter_t counter_incr )
00056    {
00057       --step_to_candidate;
00058       std::vector<bool>::size_type largestEdgelabel_p1 = 
00059          subtrie->edgelist.largestEdgelabel()+1;
00060       std::vector<bool>::size_type smallestEdgelabel = 
00061          subtrie->edgelist.smallestEdgelabel();
00062       std::vector<bool> pattern(largestEdgelabel_p1 - smallestEdgelabel, true);
00063       void* subsubtrie;
00064       for(; it_transaction != it_transaction_upper_bound; ++it_transaction)
00065          if(*it_transaction < largestEdgelabel_p1 && 
00066             *it_transaction >= smallestEdgelabel &&
00067             pattern[*it_transaction - smallestEdgelabel])
00068          {
00069             subtrie->edgelist.lookupNocheck(*it_transaction, subsubtrie);
00070             if(subsubtrie)
00071             {
00072                if( step_to_candidate ) 
00073                   findCandidates( static_cast<TRIE*>(subsubtrie),
00074                                   it_transaction_upper_bound + 1, it_transaction+1, 
00075                                   step_to_candidate, counter_incr);            
00076                else
00077                   static_cast<LEAF*>(subsubtrie)->increaseCounter( counter_incr);
00078             }
00079             pattern[*it_transaction - smallestEdgelabel] = false;
00080          }
00081    }
00082 }
00083 }
00084 #endif

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