Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
RandomStringFactory.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <ext/random>
9
10#include <alib/set>
11#include <alib/vector>
12
14
15#include <string/LinearString.h>
16
17namespace string {
18
19namespace generate {
20
26public:
37 static string::LinearString < std::string > generateLinearString ( size_t size, size_t alphabetSize, bool randomizedAlphabet, bool integerSymbols );
38
48 static string::LinearString < std::string > generateLinearString ( size_t size, size_t alphabetSize, bool randomizedAlphabet );
49
59 template < class SymbolType >
61
71 template < class SymbolType >
73};
74
75template < class SymbolType >
77 return generateLinearString ( size, ext::vector < SymbolType > ( alphabet.begin ( ), alphabet.end ( ) ) );
78}
79
80template < class SymbolType >
82
83 if ( alphabet.empty ( ) )
84 throw exception::CommonException ( "Alphabet size must be greater than 0." );
85
87
88 for ( size_t i = 0; i < size; i++ )
89 elems.push_back ( alphabet [ ext::random_devices::semirandom ( ) % alphabet.size ( ) ] );
90
92}
93
94} /* namespace generate */
95
96} /* namespace string */
97
Basic exception from which all other exceptions are derived.
Definition: CommonException.h:21
static semirandom_device & semirandom
The reference to singleton semirandom device.
Definition: random.hpp:147
Definition: set.hpp:44
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
Linear string.
Definition: LinearString.h:57
Definition: RandomStringFactory.h:25
static string::LinearString< std::string > generateLinearString(size_t size, size_t alphabetSize, bool randomizedAlphabet, bool integerSymbols)
Definition: RandomStringFactory.cpp:14
Definition: BarSymbol.cpp:12
int i
Definition: AllEpsilonClosure.h:118
Definition: RandomStringFactory.cpp:12