bpp-seq3  3.0.0
SequencePositionIterators.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_SEQ_SEQUENCEPOSITIONITERATORS_H
6 #define BPP_SEQ_SEQUENCEPOSITIONITERATORS_H
7 
8 
9 // from STL
10 #include <string>
11 
12 #include "Sequence.h"
13 
14 namespace bpp
15 {
24 {
25 public:
28 
29 public:
33  virtual unsigned int getPosition() const = 0;
38  virtual void setPosition(unsigned int pos) = 0;
42  virtual int getValue() const = 0;
46  virtual std::string getChar() const = 0;
47 
48  virtual bool operator==(const SequencePositionIterator& it) const = 0;
49  virtual bool operator!=(const SequencePositionIterator& it) const = 0;
50  virtual SequencePositionIterator& operator+=(int i) = 0;
51  virtual SequencePositionIterator& operator-=(int i) = 0;
53 
58  virtual bool hasMorePositions() const = 0;
63  virtual const Sequence& getSequence() const = 0;
64 };
65 
72  public virtual SequencePositionIterator
73 {
74 private:
76  unsigned int currentPosition_;
77 
78 public:
79  AbstractSequencePositionIterator(const Sequence& seq, unsigned int pos = 0) :
80  sequence_(&seq), currentPosition_(pos) {}
81 
84 
86  {
87  sequence_ = aspi.sequence_;
89  return *this;
90  }
91 
93 
94 public:
100  bool operator==(const SequencePositionIterator& it) const;
101  bool operator!=(const SequencePositionIterator& it) const;
104  unsigned int getPosition() const;
105  void setPosition(unsigned int pos);
106  int getValue() const;
107  std::string getChar() const;
108  const Sequence& getSequence() const;
109 };
110 
128 {
129 public:
143  SimpleSequencePositionIterator(const Sequence& seq, unsigned int pos = 0) :
154 public:
164  virtual SimpleSequencePositionIterator operator+(int i) const;
165  virtual SimpleSequencePositionIterator operator-(int i) const;
168  bool hasMorePositions() const;
169 };
170 }
171 #endif // BPP_SEQ_SEQUENCEPOSITIONITERATORS_H
Partial implementation of the SequencePositionIterator interface.
AbstractSequencePositionIterator(const AbstractSequencePositionIterator &aspi)
bool operator==(const SequencePositionIterator &it) const
AbstractSequencePositionIterator & operator=(const AbstractSequencePositionIterator &aspi)
unsigned int getPosition() const
Get the actual position of the iterator in the Sequence.
bool operator!=(const SequencePositionIterator &it) const
int getValue() const
Get the numerical value of the Sequence at current position.
const Sequence & getSequence() const
Get the Sequence on which the iterator loops.
std::string getChar() const
Get the textual value of the Sequence at current position.
AbstractSequencePositionIterator(const Sequence &seq, unsigned int pos=0)
void setPosition(unsigned int pos)
Set the position of the iterator.
virtual bool hasMorePositions() const =0
Tells if there is more positions in the Sequence.
virtual int getValue() const =0
Get the numerical value of the Sequence at current position.
virtual SequencePositionIterator & operator+=(int i)=0
virtual SequencePositionIterator & operator-=(int i)=0
virtual SequencePositionIterator & operator++()=0
virtual bool operator!=(const SequencePositionIterator &it) const =0
virtual const Sequence & getSequence() const =0
Get the Sequence on which the iterator loops.
virtual unsigned int getPosition() const =0
Get the actual position of the iterator in the Sequence.
virtual bool operator==(const SequencePositionIterator &it) const =0
virtual std::string getChar() const =0
Get the textual value of the Sequence at current position.
virtual void setPosition(unsigned int pos)=0
Set the position of the iterator.
A basic implementation of the Sequence interface.
Definition: Sequence.h:117
Loop over all positions in a Sequence.
SimpleSequencePositionIterator & operator++()
bool hasMorePositions() const
Tells if there is more positions in the Sequence.
SimpleSequencePositionIterator & operator+=(int i)
virtual SimpleSequencePositionIterator operator-(int i) const
SimpleSequencePositionIterator & operator-=(int i)
SimpleSequencePositionIterator(const Sequence &seq, unsigned int pos=0)
General constructor.
virtual SimpleSequencePositionIterator operator+(int i) const
This alphabet is used to deal NumericAlphabet.