MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / countPrefixes

Method countPrefixes

code/strings/trie.cpp:35–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33 begin++, cur = it->second; } } }
34 template<class I>
35 int countPrefixes(I begin, I end) {
36 node* cur = root;
37 while (true) {
38 if (begin == end) return cur->prefixes;
39 else {
40 T head = *begin;
41 typename map<T, node*>::const_iterator it;
42 it = cur->children.find(head);
43 if (it == cur->children.end()) return 0;
44 begin++, cur = it->second; } } } };
45// vim: cc=60 ts=2 sts=2 sw=2:

Callers 1

testFunction · 0.80

Calls 1

findMethod · 0.45

Tested by 1

testFunction · 0.64