StrTree¶
Treats a string as a tree.
-
class
cpip.util.StrTree.StrTree(theIterable=None)¶ A string tree or Trie.
-
__init__(theIterable=None)¶ Initialise the class with a optional sequence of strings.
Parameters: theIterable ( NoneType, set([str])) – A sequence of strings.Returns: NoneType
-
__weakref__¶ list of weak references to the object (if defined)
-
add(s)¶ Add a string.
Parameters: s ( str) – The string to add.Returns: NoneType
-
has(s, i=0)¶ Returns the index of the end of s that match a complete word in the tree. i.e.
[i:return_value]is in the dictionary.Parameters: - s (
cpip.util.BufGen.BufGen,str) – value - i (
int) – index
Returns: int– index.Raises: IndexError, KeyErrorNOTE: IndexError and KeyError are trapped here.- s (
-
values()¶ Returns all values.
-