A toolkit for working with phylogenetic data.
v0.18.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sample_set.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_PLACEMENT_SAMPLE_SET_H_
2 #define GENESIS_PLACEMENT_SAMPLE_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 
34 #include <string>
35 #include <vector>
36 
38 
39 namespace genesis {
40 namespace placement {
41 
42 // =================================================================================================
43 // SampleSet
44 // =================================================================================================
45 
52 class SampleSet
53 {
54 public:
55 
56  // -------------------------------------------------------------------------
57  // Typedefs
58  // -------------------------------------------------------------------------
59 
63  struct NamedSample
64  {
65  std::string name;
67  };
68 
69  typedef std::vector<NamedSample>::iterator iterator;
70  typedef std::vector<NamedSample>::const_iterator const_iterator;
71 
72  // -------------------------------------------------------------------------
73  // Constructors and Rule of Five
74  // -------------------------------------------------------------------------
75 
76  SampleSet() = default;
77  ~SampleSet() = default;
78 
79  SampleSet( SampleSet const& ) = default;
80  SampleSet( SampleSet&& ) = default;
81 
82  SampleSet& operator= ( SampleSet const& ) = default;
83  SampleSet& operator= ( SampleSet&& ) = default;
84 
85  void swap( SampleSet& other );
86 
87  // -------------------------------------------------------------------------
88  // Modifiers
89  // -------------------------------------------------------------------------
90 
96  void add( Sample const& smp );
97 
103  void add( Sample const& smp, std::string const& name );
104 
110  void add( Sample&& smp );
111 
117  void add( Sample&& smp, std::string const& name );
118 
125  void remove_at( size_t index );
126 
130  void clear();
131 
132  // -------------------------------------------------------------------------
133  // Accessors
134  // -------------------------------------------------------------------------
135 
136  iterator begin();
137  const_iterator begin() const;
138 
139  iterator end();
140  const_iterator end() const;
141 
145  NamedSample& at ( size_t index );
146 
150  const NamedSample& at ( size_t index ) const;
151 
152 
156  NamedSample& operator [] ( size_t index );
157 
161  const NamedSample& operator [] ( size_t index ) const;
162 
166  bool empty() const;
167 
171  size_t size() const;
172 
173  // -------------------------------------------------------------------------
174  // Data Members
175  // -------------------------------------------------------------------------
176 
177 private:
178 
179  std::vector<NamedSample> smps_;
180 
181 };
182 
183 } // namespace placement
184 } // namespace genesis
185 
186 #endif // include guard
SampleSet & operator=(SampleSet const &)=default
std::vector< NamedSample >::iterator iterator
Definition: sample_set.hpp:69
Store a Sample together with a name for it.
Definition: sample_set.hpp:63
void clear()
Delete all Samples in this SampleSet.
Definition: sample_set.cpp:81
NamedSample & operator[](size_t index)
Get the NamedSample at a certain index position.
Definition: sample_set.cpp:119
bool empty() const
Return whether the SampleSet is empty.
Definition: sample_set.cpp:130
Store a set of Samples with associated names.
Definition: sample_set.hpp:52
NamedSample & at(size_t index)
Get the NamedSample at a certain index position.
Definition: sample_set.cpp:110
std::vector< NamedSample >::const_iterator const_iterator
Definition: sample_set.hpp:70
size_t size() const
Return the size of the SampleSet, i.e., the number of Samples.
Definition: sample_set.cpp:135
void add(Sample const &smp)
Add a Sample to the SampleSet.
Definition: sample_set.cpp:56
Manage a set of Pqueries along with the PlacementTree where the PqueryPlacements are placed on...
Definition: sample.hpp:68
void swap(SampleSet &other)
Definition: sample_set.cpp:46
void remove_at(size_t index)
Remove the Sample at a certain index position.
Definition: sample_set.cpp:76