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 | 		yield current | ||||||
| 		current = current.succ | 		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) | # Generátor všech sourozenců (vč. sám sebe) | ||||||
| def all_brothers(node): | def all_brothers(node): | ||||||
| 	# Najdeme prvního bratra | 	# Najdeme prvního bratra | ||||||
|  | @ -103,9 +108,12 @@ def all_children(node): | ||||||
| ## Filtrační hledání | ## Filtrační hledání | ||||||
| # Najdi dalšího bratra nějakého typu, nebo None. | # 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. | # hledá i podtřídy, i.e. get_next_brother_of_type(neco, TreeNode) je prostě succ. | ||||||
| def get_next_brother_of_type(current, type): | def get_next_brother_of_type(node, type): | ||||||
| 	pass | 	for current in right_brothers(node) | ||||||
| def get_prev_brother_of_type(current, type): | 		if isinstance(current, type): | ||||||
|  | 			return current | ||||||
|  | 	 | ||||||
|  | def get_prev_brother_of_type(node, type): | ||||||
| 	pass | 	pass | ||||||
| 
 | 
 | ||||||
| # Totéž pro "the-right-order" pořadí | # Totéž pro "the-right-order" pořadí | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Pavel 'LEdoian' Turinsky
						Pavel 'LEdoian' Turinsky