📄 dfahash.cpp
字号:
#include <dfa.h>#include <ccopy.h>// #include <stream.h>#include <tools.h>#include <hash.h>#include <cursor.h>#include <iostream>#include <iterator>#include <string>using namespace std;const string USAGE = "";const string DESCRIPTION = "read a DFA from file and output hash\ value for each word read from stdin";template <typename DFA>void run(DFA &A, config &conf){ A.initial(clone(A, clone_cursor<plain>(conf.aux_input))); make_hash(A); string w; hash_cursor<forward_cursor<DFA> > c(forwardc(A)); string::const_iterator i; if (conf.verbose_mode) cerr << "Ready" << endl; for(getline(cin, w); !cin.eof(); getline(cin, w)) { for(c = A.initial(), i = w.begin(); i != w.end() && c.forward(*i); ++i); cout << w << '\t'; if (i == w.end() && c.src_final()) cout << c.hash_value(); else cout << 0; cout << endl; }} int main(int argc, char** argv){ config c(argc, argv, 2, "map bin matrix", USAGE, DESCRIPTION); if (c.representation == "map") { DFA_map<plain, hash_tag> A; run(A, c); } if (c.representation == "matrix") { DFA_matrix<plain, hash_tag> A; run(A,c ); } if (c.representation == "bin") { DFA_bin<plain, hash_tag> A; run(A, c); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -