TransformedSequence.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_TransformedSequence_h_
#define polybori_TransformedSequence_h_
// include basic definitions
#include <polybori/pbori_defs.h>
#include <polybori/iterators/TransformedIterator.h>
#include <vector>
#include <algorithm>
BEGIN_NAMESPACE_PBORI
template <class SequenceType, class OperatorType>
class TransformedSequence {
public:
typedef SequenceType sequence_type;
typedef typename sequence_type::const_iterator sequence_iterator;
typedef OperatorType operator_type;
typedef TransformedIterator<sequence_iterator, operator_type> const_iterator;
TransformedSequence(const sequence_type& seq, const operator_type& func):
m_sequence(seq), m_func(func) {
}
const_iterator begin() const {
return const_iterator(m_sequence.begin(), m_func); }
const_iterator end() const {
return const_iterator(m_sequence.end(), m_func); }
private:
sequence_type m_sequence;
operator_type m_func;
};
END_NAMESPACE_PBORI
#endif /* polybori_TransformedSequence_h_ */
polybori::TransformedIterator
This class defines the iterator of Trnasformed sequence.
Definition: TransformedIterator.h:48
END_NAMESPACE_PBORI
#define END_NAMESPACE_PBORI
Finish project's namespace.
Definition: pbori_defs.h:77
polybori::TransformedSequence::const_iterator
TransformedIterator< sequence_iterator, operator_type > const_iterator
Definition: TransformedSequence.h:40
polybori::TransformedSequence::begin
const_iterator begin() const
Sequence-like interface.
Definition: TransformedSequence.h:50
BEGIN_NAMESPACE_PBORI
#define BEGIN_NAMESPACE_PBORI
Start project's namespace.
Definition: pbori_defs.h:74
pbori_defs.h
polybori::TransformedSequence::operator_type
OperatorType operator_type
Definition: TransformedSequence.h:39
polybori::TransformedSequence::end
const_iterator end() const
Definition: TransformedSequence.h:53
polybori::TransformedSequence
This class converts a sequence-like structure when iterating.
Definition: TransformedSequence.h:34
TransformedIterator.h
polybori::TransformedSequence::TransformedSequence
TransformedSequence(const sequence_type &seq, const operator_type &func)
Construct sequence from a set of terms and an unary conversion function.
Definition: TransformedSequence.h:44
polybori::TransformedSequence::sequence_iterator
sequence_type::const_iterator sequence_iterator
Definition: TransformedSequence.h:38
polybori::TransformedSequence::sequence_type
SequenceType sequence_type
Definition: TransformedSequence.h:37