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

SimpleDFDecoder.hpp

Go to the documentation of this file.
00001 #ifndef SimpleDFDecoder_HPP
00002 #define SimpleDFDecoder_HPP
00003 
00008 #include "io/codec/decoder/SimpleDecoderBase.hpp"  
00009 #include "io/output/normal/BufferedNormalOutput.hpp" 
00010 
00011 template <class O = BufferedNormalOutput<> >
00012 class SimpleDFDecoder : public SimpleDecoderBase<O>
00013 {
00014    public:
00015 
00016       typedef typename SimpleDecoderBase<O>::params_t params_t;
00017       SimpleDFDecoder(const params_t* par)
00018          : SimpleDecoderBase<O>(par){}
00019 
00020       static bool DINLINE isDFO()
00021       {
00022          return true;
00023       }  
00024 
00025       void pushItem(item_t item)
00026       {
00027          decoded_set.push_back(this->code_inverse[item]);
00028       }
00029 
00030       void write(const counter_t support)
00031       {
00032          O::writeItemsetAndCounter( 
00033             decoded_set.begin(), decoded_set.end(), support );
00034          last_support = support;
00035       }
00036       void writeNEE( const counter_t support, 
00037                      const std::vector<item_t>& nee_items);
00038 
00039       void pushItemWithWrite(item_t item, counter_t support)
00040       {
00041          pushItem(item);
00042          write(support);            
00043       }
00044          
00045       void pushItemWithPrevSupport(item_t item)
00046       {
00047          pushItemWithWrite(item, last_support);
00048       }
00049          
00050       void popItem()
00051       {
00052          decoded_set.pop_back();
00053       }
00054 
00055    private:
00056       std::vector<item_t> decoded_set; 
00057       counter_t last_support;
00058 
00059 };
00060 
00061 template <class O> inline void 
00062 SimpleDFDecoder<O>::writeNEE( const counter_t support, 
00063                               const std::vector<item_t>& nee_items)
00064 {
00065    std::vector<bool>::size_type size =  nee_items.size();
00066    std::vector<bool> pattern( size , false);
00067    std::vector<bool>::size_type index;
00068 
00069    do
00070    {
00071       write(support);
00072       index=0;
00073       while(index < size && pattern[index] == true )
00074       {
00075          pattern[index] = false;
00076          popItem();
00077          index++;
00078       }
00079       if( index == size )
00080          break;
00081       else
00082       {
00083          pattern[index] = true;
00084          pushItem(nee_items[index]);
00085       }
00086    }
00087    while(true);
00088 }
00089 
00090 #endif

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