Skip to content

Commit

Permalink
add Node.find_all
Browse files Browse the repository at this point in the history
  • Loading branch information
malb committed May 26, 2018
1 parent e0282c5 commit a555c16
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/fpylll/tools/bkz_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,22 @@ def find(self, label, raise_keyerror=False):
else:
return None

def find_all(self, label):
"""
Find all nodes labelled ``label``
:param label: a label
"""
r = []
if self.label == label:
r.append(self)
if isinstance(self.label, tuple) and self.label[0] == label:
r.append(self)
for child in self.children:
r.extend(child.find_all(label))
return tuple(r)

def merge(self, node):
"""
Merge tree ``node`` into self.
Expand Down

0 comments on commit a555c16

Please sign in to comment.