def add(self, s):
if self.is_terminated:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if s == "<STR_LIT>":<EOL><INDENT>self._set_final(self.root)<EOL>return<EOL><DEDENT>curr = self.root<EOL>for i, a in enumerate(s):<EOL><INDENT>code = self.alphabet_codes[a]<EOL>next = self.graph[curr][code]<EOL>if next == Trie.NO_NODE:<EOL><INDENT>curr = self._add_descendant(curr, s[i:])<EOL>break<EOL><DEDENT>else:<EOL><INDENT>curr = next<EOL><DEDENT><DEDENT>self._set_final(curr)<EOL>return self<EOL>
Добавление строки s в префиксный бор