OpenStructure
Loading...
Searching...
No Matches
aligned_column_iterator.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// This file is part of the OpenStructure project <www.openstructure.org>
3//
4// Copyright (C) 2008-2020 by the OpenStructure authors
5//
6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License as published by the Free
8// Software Foundation; either version 3.0 of the License, or (at your option)
9// any later version.
10// This library is distributed in the hope that it will be useful, but WITHOUT
11// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13// details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with this library; if not, write to the Free Software Foundation, Inc.,
17// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18//------------------------------------------------------------------------------
19#ifndef OST_SEQ_ALIGNED_COLUMN_ITERATOR_HH
20#define OST_SEQ_ALIGNED_COLUMN_ITERATOR_HH
21
23
24/*
25 Author: Marco Biasini
26 */
27namespace ost { namespace seq {
28
30
31 using iterator_category = std::forward_iterator_tag;
33 using difference_type = std::ptrdiff_t;
34 using pointer = AlignedColumn*;
35 using reference = AlignedColumn&;
36
37private:
38 void UpdateVal()
39 {
40 if (curr_<end_) {
41 val_=AlignedColumn(aln_, curr_);
42 }
43 }
44public:
45 AlignedColumnIterator(const AlignmentHandle& aln, int start, int end):
46 aln_(aln), curr_(start), end_(end)
47 {
48 this->UpdateVal();
49 }
50
52 {
53 ++curr_;
54 this->UpdateVal();
55 return *this;
56 }
57
59 {
60 --curr_;
61 this->UpdateVal();
62 return *this;
63 }
64
66 {
67 AlignedColumnIterator ans(*this);
68 ++(*this);
69 return ans;
70 }
71
73 {
74 return &val_;
75 }
76
78 {
79 return val_;
80 }
81
82 bool operator==(const AlignedColumnIterator& rhs) const
83 {
84 return aln_==rhs.aln_ && rhs.curr_==curr_;
85 }
86
87 bool operator!=(const AlignedColumnIterator& rhs) const
88 {
89 return !(*this==rhs);
90 }
91private:
92 AlignmentHandle aln_;
93 int curr_;
94 int end_;
95 AlignedColumn val_;
96};
97}}
98
99#endif
Provides access to a column in a aligned region or a sequence alignment.
bool operator==(const AlignedColumnIterator &rhs) const
bool operator!=(const AlignedColumnIterator &rhs) const
AlignedColumnIterator operator++(int)
AlignedColumnIterator(const AlignmentHandle &aln, int start, int end)
representation of a multiple sequence alignemnt consisting of two or more sequences
Definition base.dox:1