|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_TAXONOMY_TAXOPATH_H_
2 #define GENESIS_TAXONOMY_TAXOPATH_H_
91 typedef std::vector< std::string >::iterator
iterator;
136 swap( elements_, other.elements_ );
148 return elements_.empty();
156 return elements_.size();
164 std::string
const&
at (
size_t index )
const
166 return elements_.at( index );
174 std::string&
at (
size_t index )
176 return elements_.at( index );
186 return elements_[ index ];
196 return elements_[ index ];
226 void assign( std::vector< std::string >
const& from )
236 elements_.push_back( value );
244 elements_.push_back( std::move( value ));
254 if( elements_.empty() ) {
255 throw std::out_of_range(
"Cannot pop last element of empty Taxopath." );
257 auto last = elements_.back();
258 elements_.pop_back();
276 return lhs.elements_ == rhs.elements_;
281 return lhs.elements_ != rhs.elements_;
286 return lhs.elements_ < rhs.elements_;
291 return lhs.elements_ <= rhs.elements_;
296 return lhs.elements_ > rhs.elements_;
301 return lhs.elements_ >= rhs.elements_;
313 return elements_.begin();
321 return elements_.end();
329 return elements_.cbegin();
337 return elements_.cend();
345 return elements_.rbegin();
353 return elements_.rend();
361 return elements_.crbegin();
369 return elements_.crend();
378 std::vector< std::string > elements_;
403 for(
auto const& e : t ) {
404 result ^= std::hash<std::string>{}( e );
411 #endif // include guard
void swap(Sample &lhs, Sample &rhs)
size_t size() const
Return the number of elements of this Taxopath.
std::string pop_back()
Remove the last element of the Taxopath and return its value.
std::vector< std::string > const & elements() const
Return the elements of the Taxopath as a vector of strings.
bool empty() const
Return whether the Taxopath is empty, i.e., does not contain any elements.
const_iterator begin() const
Return a const iterator to the beginning of the taxonomic elements.
Taxopath & operator=(Taxopath const &)=default
iterator begin()
Return an iterator to the beginning of the taxonomic elements.
void push_back(std::string const &value)
Add an element to the end of the Taxopath by copying it.
void swap(Taxopath &other)
Swap the elements of two Taxopaths.
reverse_iterator rend()
Return a reverse iterator to the reverse end of the taxonomic elements.
void assign(std::vector< std::string > const &from)
Replace the current elements of the Taxopath by a list of strings.
std::vector< std::string >::iterator iterator
Helper class to store a taxonomic path.
const_reverse_iterator rbegin() const
Return a const reverse iterator to the reverse beginning of the taxonomic elements.
friend bool operator<=(Taxopath const &lhs, Taxopath const &rhs)
void push_back(std::string &&value)
Add an element to the end of the Taxopath by moving it.
std::string & at(size_t index)
Return the taxonomic element at a certain position.
friend bool operator>(Taxopath const &lhs, Taxopath const &rhs)
const_reverse_iterator rend() const
Return a const reverse iterator to the reverse end of the taxonomic elements.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
std::vector< std::string > & elements()
Return the elements of the Taxopath as a vector of strings.
iterator end()
Return an iterator to the end of the taxonomic elements.
friend bool operator>=(Taxopath const &lhs, Taxopath const &rhs)
std::vector< std::string >::const_reverse_iterator const_reverse_iterator
void clear()
Clear all taxonomic elements. This results in an empty Taxopath.
friend bool operator==(Taxopath const &lhs, Taxopath const &rhs)
std::string const & operator[](size_t index) const
Return the taxonomic element at a certain position.
Taxopath(std::vector< std::string > &&elements)
Fill constructor that uses the given strings to initialize the taxonomic elements.
std::string const & at(size_t index) const
Return the taxonomic element at a certain position.
std::vector< std::string >::reverse_iterator reverse_iterator
result_type operator()(argument_type const &t) const
Taxopath(std::vector< std::string > const &elements)
Fill constructor that uses the given strings to initialize the taxonomic elements.
friend bool operator<(Taxopath const &lhs, Taxopath const &rhs)
friend bool operator!=(Taxopath const &lhs, Taxopath const &rhs)
std::vector< std::string >::const_iterator const_iterator
reverse_iterator rbegin()
Return a reverse iterator to the reverse beginning of the taxonomic elements.
const_iterator end() const
Return a const iterator to the end of the taxonomic elements.