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

Method insert

code/strings/trie.cpp:10–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8 trie() : root(new node()) { }
9 template <class I>
10 void insert(I begin, I end) {
11 node* cur = root;
12 while (true) {
13 cur->prefixes++;
14 if (begin == end) { cur->words++; break; }
15 else {
16 T head = *begin;
17 typename map<T, node*>::const_iterator it;
18 it = cur->children.find(head);
19 if (it == cur->children.end()) {
20 pair<T, node*> nw(head, new node());
21 it = cur->children.insert(nw).first;
22 } begin++, cur = it->second; } } }
23 template<class I>
24 int countMatches(I begin, I end) {
25 node* cur = root;

Callers 10

testFunction · 0.45
closest_pairFunction · 0.45
gift_wrapFunction · 0.45
divmodMethod · 0.45
testFunction · 0.45
iterMethod · 0.45
testFunction · 0.45
eulerFunction · 0.45
min_cost_max_flowMethod · 0.45
dijkstraFunction · 0.45

Calls 1

findMethod · 0.45

Tested by 3

testFunction · 0.36
testFunction · 0.36
testFunction · 0.36