bpp-seq3  3.0.0
SequenceContainerIterator.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_CONTAINER_SEQUENCECONTAINERITERATOR_H
6 #define BPP_SEQ_CONTAINER_SEQUENCECONTAINERITERATOR_H
7 
8 
9 #include "../Sequence.h"
10 #include "../SequenceIterator.h"
11 #include "SequenceContainer.h"
12 
13 namespace bpp
14 {
18 template<class SequenceType, class HashType = std::string>
19 class AbstractTemplateSequenceContainerIterator :
20  public virtual TemplateSequenceIteratorInterface<const SequenceType>
21 {
22 protected:
23  const TemplateSequenceContainerInterface<SequenceType, HashType>* sequences_;
24  size_t currentPosition_;
25 
26 public:
27  AbstractTemplateSequenceContainerIterator(const TemplateSequenceContainerInterface<SequenceType, HashType>& sequences) :
28  sequences_(&sequences),
29  currentPosition_(0)
30  {}
31 
32 
33  AbstractTemplateSequenceContainerIterator(const AbstractTemplateSequenceContainerIterator& atsi) :
34  sequences_(atsi.sequences_),
35  currentPosition_(atsi.currentPosition_)
36  {}
37 
38  AbstractSequenceContainerIterator& operator=(const AbstractTemplateSequenceContainerIterator& atsi)
39  {
40  sequences_ = atsi.sequences_;
41  currentPosition_ = atsi.currentPosition_;
42  return *this;
43  }
44 
45  virtual ~AbstractTemplateSequenceContainerIterator() {}
46 };
47 
51 template<class SequenceType, class HashType = std::string>
52 class SimpleTemplateSequenceContainerIterator :
53  public AbstractTemplateSequenceContainerIterator<SequenceType, HashType>
54 {
55 public:
56  SimpleSequenceContainerIterator(const TemplateSequenceContainerInterface<SequenceType, HashType>& sequences) :
57  AbstractTemplateSequenceContainerIterator<SequenceType, HashType>(&sequences) {}
58 
59  virtual ~SimpleTemplateSequenceContainerIterator() {}
60 
61 public:
62  const SequenceType& nextSequence() override
63  {
64  {
65  const Sequence& seq = sequences_->sequence(currentPosition_);
66  currentPosition_++;
67  return s;
68  }
69 
70  bool hasMoreSequences() const override
71  {
72  return currentPosition_ < sequences_->getNumberOfSequences();
73  }
74  }
75 } // end of namespace bpp.
76 #endif // BPP_SEQ_CONTAINER_SEQUENCECONTAINERITERATOR_H
This alphabet is used to deal NumericAlphabet.