1 #ifndef GENESIS_TAXONOMY_TAXOPATH_H_ 2 #define GENESIS_TAXONOMY_TAXOPATH_H_ 91 typedef std::vector< std::string >::iterator
iterator;
110 : elements_( elements )
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();
335 const_iterator
end()
const 337 return elements_.cend();
345 return elements_.rbegin();
353 return elements_.rend();
361 return elements_.crbegin();
367 const_reverse_iterator
rend()
const 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 friend bool operator<=(Taxopath const &lhs, Taxopath const &rhs)
friend bool operator>=(Taxopath const &lhs, Taxopath const &rhs)
iterator end()
Return an iterator to the end of the taxonomic elements.
friend bool operator==(Taxopath const &lhs, Taxopath const &rhs)
std::string & at(size_t index)
Return the taxonomic element at a certain position.
void assign(std::vector< std::string > const &from)
Replace the current elements of the Taxopath by a list of strings.
void push_back(std::string &&value)
Add an element to the end of the Taxopath by moving it.
void swap(SequenceSet &lhs, SequenceSet &rhs)
friend bool operator>(Taxopath const &lhs, Taxopath const &rhs)
void clear()
Clear all taxonomic elements. This results in an empty Taxopath.
std::vector< std::string >::const_reverse_iterator const_reverse_iterator
void push_back(std::string const &value)
Add an element to the end of the Taxopath by copying it.
friend bool operator!=(Taxopath const &lhs, Taxopath const &rhs)
std::vector< std::string >::reverse_iterator reverse_iterator
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
iterator begin()
Return an iterator to the beginning of the taxonomic elements.
std::vector< std::string > & elements()
Return the elements of the Taxopath as a vector of strings.
Taxopath(std::vector< std::string > &&elements)
Fill constructor that uses the given strings to initialize the taxonomic elements.
reverse_iterator rbegin()
Return a reverse iterator to the reverse beginning of the taxonomic elements.
friend bool operator<(Taxopath const &lhs, Taxopath const &rhs)
reverse_iterator rend()
Return a reverse iterator to the reverse end of the taxonomic elements.
bool empty() const
Return whether the Taxopath is empty, i.e., does not contain any elements.
std::vector< std::string >::const_iterator const_iterator
std::string pop_back()
Remove the last element of the Taxopath and return its value.
std::string const & at(size_t index) const
Return the taxonomic element at a certain position.
std::vector< std::string > const & elements() const
Return the elements of the Taxopath as a vector of strings.
Helper class to store a taxonomic path.
std::string const & operator[](size_t index) const
Return the taxonomic element at a certain position.
size_t size() const
Return the number of elements of this Taxopath.
Taxopath & operator=(Taxopath const &)=default
std::vector< std::string >::iterator iterator
const_iterator begin() const
Return a const iterator to the beginning of the taxonomic elements.
const_iterator end() const
Return a const iterator to the end of the taxonomic elements.
const_reverse_iterator rend() const
Return a const reverse iterator to the reverse end of the taxonomic elements.
Taxopath(std::vector< std::string > const &elements)
Fill constructor that uses the given strings to initialize the taxonomic elements.
result_type operator()(argument_type const &t) const
const_reverse_iterator rbegin() const
Return a const reverse iterator to the reverse beginning of the taxonomic elements.
void swap(Taxopath &other)
Swap the elements of two Taxopaths.