projects
/
treecutter.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
8505efc
)
Adding a simple iterator to the Trie class, now the set operations
author
Fredrik Unger
<fred@tree.se>
Wed, 6 Apr 2011 20:51:03 +0000
(22:51 +0200)
committer
Fredrik Unger
<fred@tree.se>
Wed, 6 Apr 2011 20:51:03 +0000
(22:51 +0200)
on the links in the tree works again.
src/tree-cutter.py
patch
|
blob
|
history
diff --git
a/src/tree-cutter.py
b/src/tree-cutter.py
index 4c0f01946f1e748d45c23bef388fbf4110ba5d3b..0b72e6b5a0d7e36b0f5295b704e49c2b917cc92f 100755
(executable)
--- a/
src/tree-cutter.py
+++ b/
src/tree-cutter.py
@@
-193,6
+193,15
@@
class Trie():
def __init__(self):
self._root = []
+ def __iter__(self):
+ return self.inorder(self._root)
+
+ def inorder(self,t):
+ for l in t:
+ yield l.value()
+ for ch in l.children():
+ self.inorder(ch)
+
def _add(self,trie, key, content):
# is the key a leaf
k = key.pop(0)