A Trie is like a dictionary in that it maps keys to values. However,
because of the way keys are stored, it allows look up based on the
longest prefix that matches. Keys must be strings.
|
|
|
|
|
isleaf(self,
key)
Return True if the key is present and it's a leaf of the Trie, False
otherwise. |
source code
|
|
|
find_prefix(self,
key)
Find as much of the key as one can, by using the longest prefix that
has a value. |
source code
|
|
|
|
|
|
|
|
|
|
|
|
|
__getitem__(self,
key)
Return the value for the given key if it is present, raises a
KeyError if key not found, and return None if it is present a key2
that starts with key. |
source code
|
|
|
__contains__(self,
key)
Return True if the key is present or if it is present a key2 string
that starts with key. |
source code
|
|
|
|
|
|