Hello,
I was wondering what people's thoughts/experiences were implementing tree data structures in rust.
For comparison I've seen this:
And this:
Advocate "memory arena" based tree structures (i.e. a vec of nodes and indices of those nodes) being preferable to Rc<RefCell<Node>> approach.
The difference between the two linked implementations as I see it is:
struct Node<T> {
first_child: usize,
last_child: usize,
}
vs
struct Node<T> {
children: Vec<usize>,
}
I.e. storing the indices of first and last child Vs a vec of children in each node. The latter seems easier to reason with and less error prone so I wondered if there were benefits to the first approach I might have missed. Or any other thoughts ![]()