3 ms·
In my sibling post on performance I go into details on the doubly-linked list problem. https://www.forrestthewoods.com/blog/solving-advent-of-code-in-under-a-se
by forrestthewoods 8y ago
In my sibling post on performance I go into details on the doubly-linked list problem. https://www.forrestthewoods.com/blog/solving-advent-of-code-in-under-a-second/ https://www.forrestthewoods.com/blog/solving-advent-of-code-...
You're right that Rust doesn't make doubly-linked lists easy. For that problem I somewhat skirted the issue. For a later problem I built an Octree. I used an Rc<RefCell<OctreeNode>>. That feels pretty gross, but I'm still not sure what the idiomatic pattern is. :(
- saghm 8y agoIn practice, most data structures like that in Rust written to be efficient for real-world make judicious use of unsafe. For something like Advent of Code, `Rc<RefCell<_>` is probably the correct way to go.
- Ar-Curunir 8y agoThe community is slowly standardising on using arena-like patterns for this kind of stuff