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

vector/SupportCounter.hpp

Go to the documentation of this file.
00001 #ifndef SupportCounter_HPP
00002 #define SupportCounter_HPP
00003 
00004 #include "apriori/bodon-vector/vector_typedef.hpp"
00005 //#include <cstdio>
00006 //#include <iterator>   //for test
00007 
00008 
00009 
00010 
00011 namespace Bodon
00012 {
00013 namespace vector_based
00014 {
00015    template<class DATA_STRUCTURE>
00016    class SupportCounter
00017    {
00018       public:
00019          SupportCounter<DATA_STRUCTURE>() {}
00020 
00021       public:
00024          void updateCounters( 
00025             DATA_STRUCTURE& candidates, const std::vector<item_t>& transaction, 
00026             const unsigned int candidate_size, const counter_t counter_incr );
00027          void updateCounters( 
00028             DATA_STRUCTURE& candidates, std::vector<item_t>::const_iterator transaction_beg, 
00029             std::vector<item_t>::const_iterator transaction_end,
00030             const unsigned int candidate_size, const counter_t counter_incr );
00031    };
00032 
00033    template<class DATA_STRUCTURE> inline
00034    void SupportCounter<DATA_STRUCTURE>::updateCounters( 
00035       DATA_STRUCTURE& candidates, const std::vector<item_t>& transaction, 
00036       const unsigned int candidate_size, const counter_t counter_incr )
00037    {
00038 //      copy(transaction.begin(), transaction.end(), ostream_iterator<item_t>(std::cout, " "));
00039 //      std::cout<<std::endl;
00040       updateCounters( 
00041          candidates, transaction.begin(), 
00042          transaction.end(), candidate_size, counter_incr);
00043 
00044    }
00045    template<class DATA_STRUCTURE> inline
00046    void SupportCounter<DATA_STRUCTURE>::updateCounters( 
00047       DATA_STRUCTURE& candidates, std::vector<item_t>::const_iterator transaction_beg, 
00048       std::vector<item_t>::const_iterator transaction_end,
00049       const unsigned int candidate_size, const counter_t counter_incr )
00050    {
00051       for(typename DATA_STRUCTURE::iterator it = candidates.begin(); 
00052           it != candidates.end(); ++it)
00053       {
00054          if((*it).first.isContained(transaction_beg, transaction_end ))
00055             (*it).second += counter_incr;
00056       }
00057    }
00058 
00059 }
00060 }
00061 #endif

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