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

Method extend

code/strings/eertree.cpp:13–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11 st[0].len = st[0].link = -1;
12 st[1].len = st[1].link = 0; }
13 int extend() {
14 char c = s[n++]; int p = last;
15 while (n - st[p].len - 2 < 0 || c != s[n - st[p].len - 2])
16 p = st[p].link;
17 if (!st[p].to[c-BASE]) {
18 int q = last = sz++;
19 st[p].to[c-BASE] = q;
20 st[q].len = st[p].len + 2;
21 do { p = st[p].link;
22 } while (p != -1 && (n < st[p].len + 2 ||
23 c != s[n - st[p].len - 2]));
24 if (p == -1) st[q].link = 1;
25 else st[q].link = st[p].to[c-BASE];
26 return 1; }
27 last = st[p].to[c-BASE];
28 return 0; } };
29// vim: cc=60 ts=2 sts=2 sw=2:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected