Project
Loading...
Searching...
No Matches
StringUtils.cxx File Reference
#include <cctype>
#include <cstdint>
#include <cmath>
#include <cstdlib>
#include <string>
#include <random>
#include <vector>
#include <list>
#include <memory>
#include <fstream>
#include <regex>
#include <map>
#include <functional>
#include <utility>
#include <sstream>
#include <istream>
#include <iomanip>
#include <iterator>
#include "DetectorsDCS/StringUtils.h"

Go to the source code of this file.

Functions

default_random_engine gen (dev())
 
uniform_int_distribution< long longuniform_dist (32, 126)
 
geometric_distribution< long longgeom_dist (0.1)
 
constexpr uint64_t MODULO (13835058055282163729ULL)
 
uint8_t lookup (const char input) noexcept
 
uint64_t exp (uint64_t base, uint8_t exp) noexcept
 
char to_alpha_numeric (const uint8_t c) noexcept
 

Variables

random_device dev
 
constexpr char ALPHABET [39]
 
constexpr uint64_t PRIMES [52]
 

Function Documentation

◆ exp()

uint64_t exp ( uint64_t  base,
uint8_t  exp 
)
noexcept

An all-integer exponent function. The orgiginal algorithm was submitted as an answer at StackOverflow, by Elias Yarrkow. The code was obtained from http://stackoverflow.com/a/101613 in 14 February 2017, 11:24, and modified to work with the unsigned C integer types. It is well-known that these kind of functions usually overflow, and overflows are ignored in this case.

Parameters
baseThe base of the exponent function.
expThe exponent.
Returns
The result.

Definition at line 192 of file StringUtils.cxx.

◆ gen()

default_random_engine gen ( dev()  )

◆ geom_dist()

geometric_distribution< long long > geom_dist ( 0.  1)

◆ lookup()

uint8_t lookup ( const char  input)
noexcept

Transforms the given character into a 8-bit unsigned code symbol.

Parameters
input
Returns

Definition at line 71 of file StringUtils.cxx.

◆ MODULO()

constexpr uint64_t MODULO ( 13835058055282163729ULL  )
constexpr

The modulo used in the hash function after calculating the sum. It is the prime number closest to 1.5 * 2^63.

◆ to_alpha_numeric()

char to_alpha_numeric ( const uint8_t  c)
inlinenoexcept

Definition at line 272 of file StringUtils.cxx.

◆ uniform_dist()

uniform_int_distribution< long long > uniform_dist ( 32  ,
126   
)

Variable Documentation

◆ ALPHABET

constexpr char ALPHABET[39]
constexpr
Initial value:
{
'E', 'T', 'A', 'O', 'I', '_', 'N', 'S', 'H', 'R',
'/', 'D', 'L', '1', '2', 'C', 'U', 'M', 'W', '3',
'4', '5', '6', '7', '8', '9', '0', 'F', 'G', 'Y',
'P', 'B', 'V', 'K', 'J', 'X', 'Q', 'Z', '?'}

Definition at line 40 of file StringUtils.cxx.

◆ dev

random_device dev

Definition at line 35 of file StringUtils.cxx.

◆ PRIMES

constexpr uint64_t PRIMES[52]
constexpr
Initial value:
{
2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
127, 131, 137, 139, 149, 151, 157, 163, 167, 173,
179, 181, 191, 193, 197, 199, 211, 223, 227, 229,
233, 239}

The first 52 prime numbers used for calculating the hash code. Each symbol of the alias will be multiplied (mod 256) with a prime of the same index and adding the obtained number to the sum that is the hash code.

Definition at line 51 of file StringUtils.cxx.