|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_UTILS_TOOLS_CHAR_LOOKUP_H_
2 #define GENESIS_UTILS_TOOLS_CHAR_LOOKUP_H_
53 template<
typename T >
97 throw std::domain_error(
104 for(
auto const& e : init ) {
129 table_[
static_cast<unsigned char>(c) ] = value;
138 table_[
static_cast<unsigned char>( toupper(c) )] = value;
139 table_[
static_cast<unsigned char>( tolower(c) )] = value;
145 void set_if( std::function<
bool (
char )> predicate, T value )
147 for(
unsigned char c = 0; c <
ArraySize; ++c ) {
159 for(
char c : chars ) {
161 table_[
static_cast<unsigned char>(c) ] = value;
171 for(
char c : chars ) {
173 table_[
static_cast<unsigned char>( toupper(c) )] = value;
174 table_[
static_cast<unsigned char>( tolower(c) )] = value;
183 for(
auto c = first; c <= last; ++c ) {
185 table_[
static_cast<unsigned char>(c) ] = value;
194 for(
unsigned char c = 0; c < 128; ++c ) {
212 return table_[
static_cast<unsigned char>(c) ];
221 return table_[
static_cast<unsigned char>(c) ];
231 for(
unsigned char c = 0; c < 128; ++c ) {
232 if(
get(c) == comp_value ) {
244 for(
unsigned char c = 0; c < 128; ++c ) {
245 if(
get(c) != comp_value ) {
258 std::array< T, ArraySize > table_;
264 #endif // include guard
void set_if(std::function< bool(char)> predicate, T value)
Set the lookup status for all chars that fulfill a given predicate.
bool all_equal_to(T comp_value) const
Return whether all chars compare equal to a given value.
CharLookup(std::initializer_list< T > init)
Constructor that takes an initializer list of the template type.
T get(char c) const
Return the lookup status for a given char.
std::string to_string(GenomeLocus const &locus)
static const size_t ArraySize
void set_selection_upper_lower(std::string const &chars, T value)
Set the lookup status for both the upper and lower case of all chars that are contained in a given st...
Simple lookup table providing a value lookup for each ASCII char (0-127).
std::string get_chars_equal_to(T comp_value) const
Return a std::string containg all chars which have lookup status equal to a given value.
void set_char(char c, T value)
Set the lookup status for a given char.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
CharLookup & operator=(CharLookup const &)=default
void set_range(char first, char last, T value)
Set the lookup status for all chars in an inlcuding range between two chars.
CharLookup(T const &init_all)
Constructor that sets all values to a given one.
CharLookup()
Constructor that sets all values to the default value of the template parameter type.
void set_char_upper_lower(char c, T value)
Set the lookup status for both the upper and lower case of a given char.
void set_all(T value)
Set the lookup status for all chars at once.
T operator[](char c) const
Return the lookup status for a given char.
void set_selection(std::string const &chars, T value)
Set the lookup status for all chars that are contained in a given std::string.