|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_PLACEMENT_SAMPLE_SET_H_
2 #define GENESIS_PLACEMENT_SAMPLE_SET_H_
62 using iterator =
typename std::vector<Sample>::iterator;
81 swap( names_, other.names_ );
82 swap( smpls_, other.smpls_ );
94 void add(
Sample const& smp, std::string
const& name =
"" )
96 names_.push_back( name );
97 smpls_.push_back( smp );
107 names_.push_back( name );
108 smpls_.push_back( std::move(smp) );
119 if( index >= smpls_.size() ) {
120 throw std::invalid_argument(
121 "Cannot remove element at index " +
std::to_string( index ) +
" from SampleSet with " +
125 assert( names_.size() == smpls_.size() );
127 names_.erase( names_.begin() + index );
128 smpls_.erase( smpls_.begin() + index );
144 std::string
const&
name_at(
size_t index )
const
146 if( index >= names_.size() ) {
147 throw std::invalid_argument(
148 "Cannot access element at index " +
std::to_string( index ) +
" from SampleSet with " +
152 return names_[index];
155 std::vector<std::string>
const&
names()
const
166 return smpls_.begin();
171 return smpls_.cbegin();
181 return smpls_.cend();
186 return smpls_.at(index);
191 return smpls_.at(index);
196 return smpls_[index];
201 return smpls_[index];
213 operator std::vector<Sample>
const&()
const
227 assert( names_.empty() == smpls_.empty() );
228 return smpls_.empty();
236 assert( names_.size() == smpls_.size() );
237 return smpls_.size();
246 std::vector<std::string> names_;
247 std::vector<Sample> smpls_;
254 #endif // include guard
void swap(Sample &lhs, Sample &rhs)
SampleSet & operator=(SampleSet const &)=default
void add(Sample &&smp, std::string const &name="")
Add a Sample with a name to the SampleSet.
Store a set of Samples with associated names.
void add(Sample const &smp, std::string const &name="")
Add a Sample with a name to the SampleSet.
Manage a set of Pqueries along with the PlacementTree where the PqueryPlacements are placed on.
typename std::vector< Sample >::iterator iterator
Sample const & at(size_t index) const
bool empty() const
Return whether the SampleSet is empty.
Sample & operator[](size_t index)
std::string to_string(GenomeLocus const &locus)
std::vector< Sample > const & samples() const
std::vector< std::string > const & names() const
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
void clear()
Delete all Samples in this SampleSet.
void remove_at(size_t index)
Remove the Sample at a certain index position.
const_iterator end() const
const_iterator begin() const
size_t size() const
Return the size of the SampleSet, i.e., the number of Samples.
Sample & at(size_t index)
std::string const & name_at(size_t index) const
typename std::vector< Sample >::const_iterator const_iterator
void swap(SampleSet &other)