Treelib: get_next_brother_of_type
This commit is contained in:
		
							parent
							
								
									63dd0da97c
								
							
						
					
					
						commit
						bf96cac66f
					
				
					 1 changed files with 11 additions and 3 deletions
				
			
		|  | @ -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í | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Pavel 'LEdoian' Turinsky
						Pavel 'LEdoian' Turinsky