| 22 | } begin++, cur = it->second; } } } |
| 23 | template<class I> |
| 24 | int countMatches(I begin, I end) { |
| 25 | node* cur = root; |
| 26 | while (true) { |
| 27 | if (begin == end) return cur->words; |
| 28 | else { |
| 29 | T head = *begin; |
| 30 | typename map<T, node*>::const_iterator it; |
| 31 | it = cur->children.find(head); |
| 32 | if (it == cur->children.end()) return 0; |
| 33 | begin++, cur = it->second; } } } |
| 34 | template<class I> |
| 35 | int countPrefixes(I begin, I end) { |
| 36 | node* cur = root; |