2 ms·
There are other both more useful and harder to generalize structures like various kinds of trees for example. Trees are usually easy because each node has a si
by Silhouette 6y ago
There are other both more useful and harder to generalize structures like various kinds of trees for example.
Trees are usually easy because each node has a single parent all the way up to the root and ownership can follow the same hierarchy. More general graphs are a little more tricky, but the same techniques that you can use to implement a specific case like a DLL generalise. For example, in Rust, you can combine Option and Rc to handle, respectively, the intermediate states while the structure is being manipulated and the shared ownership semantics.