A library for working with phylogenetic and population genetic data.
v0.32.0
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 (CharLookup &&)=default
 
 CharLookup (CharLookup const &)=default
 
 CharLookup (std::initializer_list< T > init)
 Constructor that takes an initializer list of the template type. More...
 
 CharLookup (T const &init_all)
 Constructor that sets all values to a given one. More...
 
 ~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 &&)=default
 
CharLookupoperator= (CharLookup const &)=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() [1/5]

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() [2/5]

CharLookup ( T const &  init_all)
inlineexplicit

Constructor that sets all values to a given one.

Definition at line 81 of file char_lookup.hpp.

◆ CharLookup() [3/5]

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

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()

~CharLookup ( )
default

◆ CharLookup() [4/5]

CharLookup ( CharLookup< T > const &  )
default

◆ CharLookup() [5/5]

CharLookup ( CharLookup< T > &&  )
default

Member Function Documentation

◆ all_equal_to()

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.

◆ get()

T get ( char  c) const
inline

Return the lookup status for a given char.

Definition at line 218 of file char_lookup.hpp.

◆ get_chars_equal_to()

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.

◆ operator=() [1/2]

CharLookup& operator= ( CharLookup< T > &&  )
default

◆ operator=() [2/2]

CharLookup& operator= ( CharLookup< T > const &  )
default

◆ operator[]()

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.

◆ set_all()

void set_all ( value)
inline

Set the lookup status for all chars at once.

Definition at line 192 of file char_lookup.hpp.

◆ set_char()

void set_char ( char  c,
value 
)
inline

Set the lookup status for a given char.

Definition at line 126 of file char_lookup.hpp.

◆ set_char_upper_lower()

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.

◆ set_if()

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.

◆ set_range()

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.

◆ set_selection()

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.

◆ set_selection_upper_lower()

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

◆ key_type

using key_type = char

Definition at line 63 of file char_lookup.hpp.

◆ value_type

using value_type = T

Definition at line 62 of file char_lookup.hpp.

Member Data Documentation

◆ ArraySize

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: