Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
BadCharacterShiftTable.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <alib/set>
9#include <alib/map>
10
11#include <string/LinearString.h>
12
13namespace string {
14
15namespace properties {
16
22public:
27 template < class SymbolType >
29
30};
31
32template < class SymbolType >
34 const ext::set<SymbolType>& alphabet = pattern.getAlphabet();
36
37 /* Initialization of BCS to the length of the needle. */
38 for(const auto& symbol : alphabet)
39 bcs.insert(std::make_pair(symbol, pattern.getContent().size()));
40
41 /* Filling out BCS, ignoring last character. */
42 for(size_t i = 0; i < pattern.getContent().size() - 1; i++)
43 bcs[pattern.getContent().at(i)] = pattern.getContent().size() - i - 1;
44
45 /*
46 for(const auto& kv: bcs)
47 common::Streams::out << std::string(kv.first) << " " << kv.second << std::endl;
48 for(const auto& s: string.getContent())
49 common::Streams::out << std::string(s);common::Streams::out << std::endl;
50 */
51
52 return bcs;
53}
54
55} /* namespace properties */
56
57} /* namespace string */
58
Class extending the map class from the standard library. Original reason is to allow printing of the ...
Definition: map.hpp:48
Definition: set.hpp:44
Linear string.
Definition: LinearString.h:57
const ext::set< SymbolType > & getAlphabet() const &
Definition: LinearString.h:103
const ext::vector< SymbolType > & getContent() const &
Definition: LinearString.h:238
Definition: BadCharacterShiftTable.h:21
static ext::map< SymbolType, size_t > bcs(const string::LinearString< SymbolType > &pattern)
Definition: BadCharacterShiftTable.h:33
Definition: BarSymbol.cpp:12
int i
Definition: AllEpsilonClosure.h:118
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79
Definition: RandomStringFactory.cpp:12