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

SortedTransactionReader.hpp

Go to the documentation of this file.
00001 #ifndef SortedTransactionReader_HPP
00002 #define SortedTransactionReader_HPP
00003 
00008 #include "common.hpp"
00009 #include "io/input/transaction_reader/TransactionReader.hpp"  
00010 #include <algorithm>
00011 
00018 template <class T_R = TransactionReader<>, bool UNIQUE = false, bool ASCENDING=true> 
00019 class SortedTransactionReader : public T_R
00020 {
00021    public:
00022       typedef typename T_R::params_t params_t;
00023       SortedTransactionReader( const params_t* par ) : T_R(par){}
00024 
00025       template <class BIS> counter_t nextTransactionBIS( BIS& transaction )
00026       {
00027          counter_t return_value = T_R::nextTransactionBIS(transaction);
00028          if( ASCENDING )
00029             std::sort(transaction.begin(), transaction.end());
00030          else 
00031             std::sort(transaction.begin(), transaction.end(), std::greater<item_t>());
00032          if( UNIQUE )
00033             transaction.erase(
00034                std::unique( transaction.begin(), transaction.end() ),
00035                transaction.end() );      
00036          return return_value;
00037       }
00038 };
00039 
00040 #endif

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