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

SupportCounterLookupEdgeCommute.hpp

Go to the documentation of this file.
00001 #ifndef SupportCounterLookupEdgeCommute_HPP
00002 #define SupportCounterLookupEdgeCommute_HPP
00003 
00004 #include "common.hpp"
00005 #include <vector>
00006 #include "apriori/bodon/Leaf.hpp"
00007 //#include <cstdio>
00008 //#include <iterator>   //for test
00009 
00010 
00011 
00012 
00013 namespace Bodon
00014 {
00015 namespace sequence
00016 {
00017    template <class TRIE>
00018    class SupportCounterLookupEdgeCommute
00019    {
00020       public:
00021          SupportCounterLookupEdgeCommute( ){}
00022 
00025          void findCandidates( TRIE* subtrie,
00026             std::vector<item_t>::const_iterator it_transaction_upper_bound,
00027             std::vector<item_t>::const_iterator it_transaction, 
00028             item_t step_to_candidate,
00029             const counter_t counter_incr );
00030    };
00031 
00032    template <class TRIE> void 
00033    SupportCounterLookupEdgeCommute<TRIE>::findCandidates( 
00034       TRIE* subtrie, std::vector<item_t>::const_iterator 
00035       it_transaction_upper_bound,
00036       std::vector<item_t>::const_iterator it_transaction, 
00037       item_t step_to_candidate, const counter_t counter_incr )
00038    {
00039       --step_to_candidate;
00040       std::vector<bool>::size_type largestEdgelabel_p1 = 
00041          subtrie->edgelist.largestEdgelabel()+1;
00042       std::vector<bool>::size_type smallestEdgelabel = 
00043          subtrie->edgelist.smallestEdgelabel();
00044       std::vector<bool> pattern(largestEdgelabel_p1 - smallestEdgelabel, true);
00045       typename TRIE::iterator it_edge(subtrie->edgelist.begin());
00046       for(; it_transaction != it_transaction_upper_bound; ++it_transaction)
00047          if(*it_transaction < largestEdgelabel_p1 && 
00048             *it_transaction >= smallestEdgelabel &&
00049             pattern[*it_transaction - smallestEdgelabel])
00050          {
00051             if((*it_edge).first < *it_transaction)
00052                subtrie->edgelist.findForwardNoBoundaryCheck(*it_transaction, it_edge);
00053             else
00054                subtrie->edgelist.findBackwardNoBoundaryCheck(*it_transaction, it_edge);
00055             
00056             if((*it_edge).first == *it_transaction)
00057                if( step_to_candidate ) 
00058                   findCandidates( static_cast<TRIE*>((*it_edge).second),
00059                                   it_transaction_upper_bound + 1, it_transaction+1, 
00060                                   step_to_candidate, counter_incr);       
00061                else
00062                   static_cast<Leaf*>((*it_edge).second)->increaseCounter( counter_incr);
00063             pattern[*it_transaction - smallestEdgelabel] = false;
00064          }
00065    }
00066 }
00067 }
00068 #endif

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