00001 // -*- c++ -*- 00002 //***************************************************************************** 00014 //***************************************************************************** 00015 00016 #ifndef polybori_TransformedSequence_h_ 00017 #define polybori_TransformedSequence_h_ 00018 00019 // include basic definitions 00020 #include <polybori/pbori_defs.h> 00021 #include <polybori/iterators/TransformedIterator.h> 00022 00023 #include <vector> 00024 #include <algorithm> 00025 00026 BEGIN_NAMESPACE_PBORI 00027 00028 00033 template <class SequenceType, class OperatorType> 00034 class TransformedSequence { 00035 00036 public: 00037 typedef SequenceType sequence_type; 00038 typedef typename sequence_type::const_iterator sequence_iterator; 00039 typedef OperatorType operator_type; 00040 typedef TransformedIterator<sequence_iterator, operator_type> const_iterator; 00041 00042 00044 TransformedSequence(const sequence_type& seq, const operator_type& func): 00045 m_sequence(seq), m_func(func) { 00046 } 00047 00049 00050 const_iterator begin() const { 00051 return const_iterator(m_sequence.begin(), m_func); } 00052 00053 const_iterator end() const { 00054 return const_iterator(m_sequence.end(), m_func); } 00056 00057 private: 00058 sequence_type m_sequence; 00059 operator_type m_func; 00060 }; 00061 00062 00063 END_NAMESPACE_PBORI 00064 00065 #endif /* polybori_TransformedSequence_h_ */