Adding upstream version 6.0.4.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
d01130b3f1
commit
527597d2af
122 changed files with 23162 additions and 0 deletions
27
sqlglot/trie.py
Normal file
27
sqlglot/trie.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
def new_trie(keywords):
|
||||
trie = {}
|
||||
|
||||
for key in keywords:
|
||||
current = trie
|
||||
|
||||
for char in key:
|
||||
current = current.setdefault(char, {})
|
||||
current[0] = True
|
||||
|
||||
return trie
|
||||
|
||||
|
||||
def in_trie(trie, key):
|
||||
if not key:
|
||||
return (0, trie)
|
||||
|
||||
current = trie
|
||||
|
||||
for char in key:
|
||||
if char not in current:
|
||||
return (0, current)
|
||||
current = current[char]
|
||||
|
||||
if 0 in current:
|
||||
return (2, current)
|
||||
return (1, current)
|
Loading…
Add table
Add a link
Reference in a new issue