A toolkit for working with phylogenetic data.
v0.19.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sequence_set.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_SEQUENCE_SEQUENCE_SET_H_
2 #define GENESIS_SEQUENCE_SEQUENCE_SET_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2017 Lucas Czech
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21  Contact:
22  Lucas Czech <lucas.czech@h-its.org>
23  Exelixis Lab, Heidelberg Institute for Theoretical Studies
24  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
25 */
26 
35 
36 #include <vector>
37 
38 namespace genesis {
39 namespace sequence {
40 
41 // =================================================================================================
42 // Forward Declarations
43 // =================================================================================================
44 
45 class SequenceSet;
46 void swap( SequenceSet& lhs, SequenceSet& rhs );
47 
48 // =================================================================================================
49 // SequenceSet
50 // =================================================================================================
51 
60 {
61 public:
62 
63  // -------------------------------------------------------------------------
64  // Typedefs and Enums
65  // -------------------------------------------------------------------------
66 
67  typedef std::vector<Sequence>::iterator iterator;
68  typedef std::vector<Sequence>::const_iterator const_iterator;
69 
70  typedef Sequence& reference;
71  typedef Sequence const& const_reference;
72 
73  // -------------------------------------------------------------------------
74  // Constructors and Rule of Five
75  // -------------------------------------------------------------------------
76 
77  SequenceSet() = default;
78  ~SequenceSet() = default;
79 
80  SequenceSet( SequenceSet const& ) = default;
81  SequenceSet( SequenceSet&& ) = default;
82 
83  SequenceSet& operator= ( SequenceSet const& ) = default;
84  SequenceSet& operator= ( SequenceSet&& ) = default;
85 
86  friend void swap( SequenceSet& lhs, SequenceSet& rhs );
87 
88  // -------------------------------------------------------------------------
89  // Accessors
90  // -------------------------------------------------------------------------
91 
95  size_t size() const;
96 
100  bool empty() const;
101 
102  reference at ( size_t index );
103  const_reference at ( size_t index ) const;
104 
105  reference operator[] ( size_t index );
106  const_reference operator[] ( size_t index ) const;
107 
108  // -------------------------------------------------------------------------
109  // Modifiers
110  // -------------------------------------------------------------------------
111 
115  reference add( Sequence const& s );
116 
120  reference add( Sequence && s );
121 
125  void remove( size_t index );
126 
131  void remove( size_t first_index, size_t last_index );
132 
136  void remove( iterator position );
137 
142  void remove( iterator first, iterator last );
143 
147  void clear();
148 
149  // -------------------------------------------------------------------------
150  // Iterators
151  // -------------------------------------------------------------------------
152 
153  iterator begin();
154  iterator end();
155 
156  const_iterator begin() const;
157  const_iterator end() const;
158 
159  const_iterator cbegin() const;
160  const_iterator cend() const;
161 
162  // -------------------------------------------------------------------------
163  // Data Members
164  // -------------------------------------------------------------------------
165 
166 private:
167 
168  std::vector<Sequence> sequences_;
169 };
170 
171 } // namespace sequence
172 } // namespace genesis
173 
174 #endif // include guard
reference at(size_t index)
void swap(SequenceSet &lhs, SequenceSet &rhs)
friend void swap(SequenceSet &lhs, SequenceSet &rhs)
void clear()
Remove all Sequences from the SequenceSet, leaving it with a size() of 0.
const_iterator cend() const
Sequence const & const_reference
std::vector< Sequence >::const_iterator const_iterator
const_iterator cbegin() const
Store a set of Sequences.
std::vector< Sequence >::iterator iterator
SequenceSet & operator=(SequenceSet const &)=default
reference add(Sequence const &s)
Add a Sequence to the SequenceSet by copying it, and return a reference to it.
reference operator[](size_t index)