A toolkit for working with phylogenetic data.
v0.20.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CharLookup< T > Class Template Reference

#include <genesis/utils/tools/char_lookup.hpp>

Detailed Description

template<typename T>
class genesis::utils::CharLookup< T >

Simple lookup table providing a value lookup for each ASCII char (0-127).

The class provides a fast mapping from each char to the provided template parameter type.

Definition at line 54 of file char_lookup.hpp.

Public Member Functions

 CharLookup ()
 Constructor that sets all values to the default value of the template parameter type. More...
 
 CharLookup (T const &init_all)
 Constructor that sets all values to a given one. More...
 
 CharLookup (std::initializer_list< T > init)
 Constructor that takes an initializer list of the template type. More...
 
 CharLookup (CharLookup const &)=default
 
 CharLookup (CharLookup &&)=default
 
 ~CharLookup ()=default
 
bool all_equal_to (T comp_value) const
 Return whether all chars compare equal to a given value. More...
 
get (char c) const
 Return the lookup status for a given char. More...
 
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. More...
 
CharLookupoperator= (CharLookup const &)=default
 
CharLookupoperator= (CharLookup &&)=default
 
operator[] (char c) const
 Return the lookup status for a given char. More...
 
void set_all (T value)
 Set the lookup status for all chars at once. More...
 
void set_char (char c, T value)
 Set the lookup status for a given char. More...
 
void set_char_upper_lower (char c, T value)
 Set the lookup status for both the upper and lower case of a given char. More...
 
void set_if (std::function< bool(char)> predicate, T value)
 Set the lookup status for all chars that fulfill a given predicate. More...
 
void set_range (char first, char last, T value)
 Set the lookup status for all chars in an inlcuding range between two chars. More...
 
void set_selection (std::string const &chars, T value)
 Set the lookup status for all chars that are contained in a given std::string. More...
 
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 std::string. More...
 

Public Types

using key_type = char
 
using value_type = T
 

Static Public Attributes

static const size_t ArraySize = 128
 

Constructor & Destructor Documentation

CharLookup ( )
inline

Constructor that sets all values to the default value of the template parameter type.

Definition at line 74 of file char_lookup.hpp.

CharLookup ( T const &  init_all)
inline

Constructor that sets all values to a given one.

Definition at line 81 of file char_lookup.hpp.

CharLookup ( std::initializer_list< T >  init)
inline

Constructor that takes an initializer list of the template type.

The given list needs to have as many entries as the lookup table itself (see ArraySize), otherwise it throws.

Definition at line 94 of file char_lookup.hpp.

~CharLookup ( )
default
CharLookup ( CharLookup< T > const &  )
default
CharLookup ( CharLookup< T > &&  )
default

Member Function Documentation

bool all_equal_to ( comp_value) const
inline

Return whether all chars compare equal to a given value.

Definition at line 242 of file char_lookup.hpp.

T get ( char  c) const
inline

Return the lookup status for a given char.

Definition at line 218 of file char_lookup.hpp.

std::string get_chars_equal_to ( comp_value) const
inline

Return a std::string containg all chars which have lookup status equal to a given value.

Definition at line 228 of file char_lookup.hpp.

CharLookup& operator= ( CharLookup< T > const &  )
default
CharLookup& operator= ( CharLookup< T > &&  )
default
T operator[] ( char  c) const
inline

Return the lookup status for a given char.

We only provide the const getter version of this operator in order to avoid accidentally setting the value. Use one of the set...() functions explicitily for this.

Definition at line 209 of file char_lookup.hpp.

void set_all ( value)
inline

Set the lookup status for all chars at once.

Definition at line 192 of file char_lookup.hpp.

void set_char ( char  c,
value 
)
inline

Set the lookup status for a given char.

Definition at line 126 of file char_lookup.hpp.

void set_char_upper_lower ( char  c,
value 
)
inline

Set the lookup status for both the upper and lower case of a given char.

Definition at line 135 of file char_lookup.hpp.

void set_if ( std::function< bool(char)>  predicate,
value 
)
inline

Set the lookup status for all chars that fulfill a given predicate.

Definition at line 145 of file char_lookup.hpp.

void set_range ( char  first,
char  last,
value 
)
inline

Set the lookup status for all chars in an inlcuding range between two chars.

Definition at line 181 of file char_lookup.hpp.

void set_selection ( std::string const &  chars,
value 
)
inline

Set the lookup status for all chars that are contained in a given std::string.

Definition at line 157 of file char_lookup.hpp.

void set_selection_upper_lower ( std::string const &  chars,
value 
)
inline

Set the lookup status for both the upper and lower case of all chars that are contained in a given std::string.

Definition at line 169 of file char_lookup.hpp.

Member Typedef Documentation

using key_type = char

Definition at line 63 of file char_lookup.hpp.

using value_type = T

Definition at line 62 of file char_lookup.hpp.

Member Data Documentation

const size_t ArraySize = 128
static

Definition at line 65 of file char_lookup.hpp.


The documentation for this class was generated from the following file: