Plan data structure refactoring to avoid Rc and RefCell, totally optionnal but nice way to learn
This commit is contained in:
		
							parent
							
								
									51dca7ac7e
								
							
						
					
					
						commit
						d384c196b7
					
				| @ -42,6 +42,10 @@ pub struct SpaceColonization { | |||||||
|     ///
 |     ///
 | ||||||
|     /// If density is 10, then there will be an average distance of 10 between attractors
 |     /// If density is 10, then there will be an average distance of 10 between attractors
 | ||||||
|     density: i32, |     density: i32, | ||||||
|  |     // TODO learning opportunity : avoid Rc and RefCell to have memory contiguous, increase
 | ||||||
|  |     // performance and simplify code. Using a mutable struct instead of pointers to nodeswill
 | ||||||
|  |     // improve performance. If required, use ids to point to nodes, those ids can be simply their
 | ||||||
|  |     // indices in the array. If the node pointed to is deep, the index can be a vec or a tuple.
 | ||||||
|     new_nodes: RefCell<Vec<(Rc<Node>, Rc<Node>)>>, |     new_nodes: RefCell<Vec<(Rc<Node>, Rc<Node>)>>, | ||||||
|     /// Tree like representation of all nodes
 |     /// Tree like representation of all nodes
 | ||||||
|     /// [node: [child1: [grand-child], child2: [grand-child2]]]
 |     /// [node: [child1: [grand-child], child2: [grand-child2]]]
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user