A toolkit for working with phylogenetic data.
v0.18.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sample_set.cpp
Go to the documentation of this file.
1 /*
2  Genesis - A toolkit for working with phylogenetic data.
3  Copyright (C) 2014-2017 Lucas Czech
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  Contact:
19  Lucas Czech <lucas.czech@h-its.org>
20  Exelixis Lab, Heidelberg Institute for Theoretical Studies
21  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
22 */
23 
32 
36 
37 #include <sstream>
38 
39 namespace genesis {
40 namespace placement {
41 
42 // =================================================================================================
43 // Constructors and Rule of Five
44 // =================================================================================================
45 
46 void SampleSet::swap( SampleSet& other )
47 {
48  using std::swap;
49  swap( smps_, other.smps_ );
50 }
51 
52 // =================================================================================================
53 // Modifiers
54 // =================================================================================================
55 
56 void SampleSet::add( Sample const& smp )
57 {
58  smps_.push_back( { "", smp } );
59 }
60 
61 void SampleSet::add( Sample const& smp, std::string const& name )
62 {
63  smps_.push_back( { name, smp } );
64 }
65 
66 void SampleSet::add( Sample&& smp )
67 {
68  smps_.push_back( { "", std::move(smp) } );
69 }
70 
71 void SampleSet::add( Sample&& smp, std::string const& name )
72 {
73  smps_.push_back( { name, std::move(smp) } );
74 }
75 
76 void SampleSet::remove_at( size_t index )
77 {
78  smps_.erase( smps_.begin() + index );
79 }
80 
82 {
83  smps_.clear();
84 }
85 
86 // =================================================================================================
87 // Accessors
88 // =================================================================================================
89 
91 {
92  return smps_.begin();
93 }
94 
96 {
97  return smps_.end();
98 }
99 
101 {
102  return smps_.cbegin();
103 }
104 
106 {
107  return smps_.cend();
108 }
109 
111 {
112  return smps_.at(index);
113 }
114 SampleSet::NamedSample const& SampleSet::at ( size_t index ) const
115 {
116  return smps_.at(index);
117 }
118 
120 {
121  return smps_[index];
122 }
123 
125 {
126  return smps_[index];
127 }
128 
129 
130 bool SampleSet::empty() const
131 {
132  return smps_.empty();
133 }
134 
135 size_t SampleSet::size() const
136 {
137  return smps_.size();
138 }
139 
140 } // namespace placement
141 } // namespace genesis
std::vector< NamedSample >::iterator iterator
Definition: sample_set.hpp:69
void swap(SequenceSet &lhs, SequenceSet &rhs)
Store a Sample together with a name for it.
Definition: sample_set.hpp:63
Provides functions for working with Placements and Pqueries.
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
Provides easy and fast logging functionality.
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