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

trie/trie_manipulators/FrequentItemInserter.hpp

Go to the documentation of this file.
00001 #ifndef FrequentItemInserter_HPP
00002 #define FrequentItemInserter_HPP
00003 
00004 #include "common.hpp"
00005 #include "common/Edge.hpp"
00006 #include "apriori/bodon/trie/trie_manipulators/ManipulatorBase.hpp"
00007 #include <vector>
00008 //#include <cstdio>
00009 //#include <iterator>   //for test
00010 
00011 namespace Bodon
00012 {
00013 
00014 template <class DF_D, class TRIE, bool NEE>
00015 class FrequentItemInserter : public ManipulatorBase<DF_D, TRIE>
00016 {
00017    private:
00018       typedef ManipulatorBase<DF_D, TRIE> PARENT;
00019    public:
00020       FrequentItemInserter( TRIE& trie, DF_D& df_decoder ) : 
00021          PARENT(trie, df_decoder){}
00022 
00024       void setEmptysetSupport(const counter_t emptyset_support)
00025       {PARENT::main_trie.setCounter(emptyset_support);}
00026 
00028       void insertFrequentItems(const std::vector<counter_t>& freq_counters )
00029       {
00030          std::vector<Edge> extenders;
00031          if(NEE)
00032          {
00033             for(item_t index = 0; index < freq_counters.size(); ++index)
00034             {
00035                if( freq_counters[index] == PARENT::main_trie.getCounter())
00036                   PARENT::main_trie.neelist.push_back(index);
00037                else
00038                   extenders.push_back(Edge(index, 
00039                                            new TRIE(freq_counters[index])));
00040             }
00041          }
00042          else
00043          {
00044             PARENT::df_decoder.write(PARENT::main_trie.getCounter());
00045             for(item_t index = 0; index < freq_counters.size(); ++index)
00046             {
00047                PARENT::df_decoder.pushItemWithWrite( index, freq_counters[index] );
00048                extenders.push_back(Edge(index, 
00049                                         new TRIE(freq_counters[index])));
00050                PARENT::df_decoder.popItem();
00051             }
00052          }
00053          PARENT::main_trie.edgelist.insert(extenders);
00054       }
00055 };
00056 
00057 }
00058 
00059 
00060 
00061 #endif

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