Treelib: get_next_brother_of_type

This commit is contained in:
Pavel 'LEdoian' Turinsky 2020-03-18 22:40:06 +01:00
parent 63dd0da97c
commit bf96cac66f

View file

@ -77,6 +77,11 @@ def me_and_right_brothers(node):
yield current
current = current.succ
def right_brothers(node):
generator = me_and_right_brothers(node.succ)
for item in generator:
yield item
# Generátor všech sourozenců (vč. sám sebe)
def all_brothers(node):
# Najdeme prvního bratra
@ -103,9 +108,12 @@ def all_children(node):
## Filtrační hledání
# Najdi dalšího bratra nějakého typu, nebo None.
# hledá i podtřídy, i.e. get_next_brother_of_type(neco, TreeNode) je prostě succ.
def get_next_brother_of_type(current, type):
pass
def get_prev_brother_of_type(current, type):
def get_next_brother_of_type(node, type):
for current in right_brothers(node)
if isinstance(current, type):
return current
def get_prev_brother_of_type(node, type):
pass
# Totéž pro "the-right-order" pořadí