Plan data structure refactoring to avoid Rc and RefCell, totally optionnal but nice way to learn

This commit is contained in:
Jean-Gabriel Gill-Couture 2023-07-26 22:22:34 -04:00
parent 51dca7ac7e
commit d384c196b7

View File

@ -42,6 +42,10 @@ pub struct SpaceColonization {
///
/// If density is 10, then there will be an average distance of 10 between attractors
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>)>>,
/// Tree like representation of all nodes
/// [node: [child1: [grand-child], child2: [grand-child2]]]