本文整理汇总了C++中Alphabet::get_string方法的典型用法代码示例。如果您正苦于以下问题:C++ Alphabet::get_string方法的具体用法?C++ Alphabet::get_string怎么用?C++ Alphabet::get_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alphabet
的用法示例。
在下文中一共展示了Alphabet::get_string方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reset_error
void State::reset_error()
{
Alphabet* alpha = Alphabet::get_alphabet();
for (int idx = 0; idx < alpha->get_string()->size(); idx++) {
char c = alpha->get_string()->at(idx);
this->map_transitions[c] = this->get_error();
}
}
示例2: build_word
void State::build_word(bool allowed, string* word, size_t len)
{
if (len == 0) {
return;
}
if (this->error_state) {
if (allowed) {
return;
}
}
if (this->get_end_state() && allowed) {
cout << "Accepting word: " << *word << endl;
} else if (!this->get_end_state() && !allowed) {
cout << "Rejecting word: " << *word << endl;
}
Alphabet* alpha = Alphabet::get_alphabet();
std::string* alpha_str = alpha->get_string();
for (size_t i = 0; i < alpha->get_size(); i++) {
string tmp_string = *word;
char c = (*alpha_str)[i];
tmp_string.push_back(c);
this->map_transitions[c]->build_word(allowed, &tmp_string,
len - 1);
}
}
示例3:
State::State(size_t location, string name) :
NFA::State(location, name)
{
stringstream name_str;
name_str << "q_" << unique_id_alloc++;
this->name = name_str.str();
error_state = false;
this->map_transitions = map<char, State*>();
Alphabet* alpha = Alphabet::get_alphabet();
for (int idx = 0; idx < alpha->get_string()->size(); idx++) {
char c = alpha->get_string()->at(idx);
this->map_transitions[c] = this->get_error();
}
}
示例4: get_dot_graph
void State::get_dot_graph(std::string* str, std::string* end_claim)
{
if (this->graphed) {
return;
}
graphed = true;
Alphabet* alpha = Alphabet::get_alphabet();
if (this->error_state) {
str->append(this->name);
str->append(" -> ");
str->append(this->name);
str->append(" [ label = \"");
str->append(*alpha->get_string());
str->append("\" ];");
return;
}
for (size_t idx = 0; idx < alpha->get_size(); idx++) {
char c = (*alpha->get_string())[idx];
State* s = this->map_transitions[c];
if (s == NULL) {
cerr << "Ayeeee!!!!!" << endl;
exit(-9005);
}
if (this->get_end_state()) {
end_claim->append(this->name);
end_claim->append("[shape = doublecircle ];\n");
}
str->append(this->name);
str->append(" -> ");
str->append(*s->get_name());
str->append(" [label=\"");
str->push_back(c);
str->append("\"];\n");
s->get_dot_graph(str, end_claim);
}
}