Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef int word_id;
- typedef unordered_multimap<uint64_t, word_id> graph_t;
- void build_graph(graph_t & G, vector<string> words)
- {
- uint64_t basket = 0;
- for(int w_id = 0; w_id < words.size(); ++w_id)
- {
- const string & S = words[i];
- const size_t L = S.length();
- assert(L <= 8);
- uint64_t word = *((uint64_t*)S.c_str());
- for(int ch = 0; ch < L; ++ch)
- {
- uint64_t mask = &(0xFF << (ch * 8));
- basket = mask & word;
- G.insert(basket, w_id);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment