rust-unofficial / too-many-lists

Learn Rust by writing Entirely Too Many linked lists
https://rust-unofficial.github.io/too-many-lists/
MIT License
3.16k stars 276 forks source link

Multi-level linked lists #282

Open offthepiste opened 11 months ago

offthepiste commented 11 months ago

Complete newbie here....

I have been trying to find some reference to "multi-level linked lists" within the Rust community to no avail. And was wondering if this would be an interesting addition to "too many linked lists".

By multi-level linked lists I also mean an "n-ary" (non binary tree) of n leaf nodes and m levels. That is it aka a directed acyclic graph.

(Perhaps I am over thinking this ... and someone will point out that what I am talking about is a simple linked list where one list item / node can simply "branch" into one or more head items / leaf nodes?)

My "use case" does not require any double linking ... simply a straight hierarchy which will only branch at the list head / leaf node (that is, it will only append and is immutable) and grow .. thankfully not infinitely.

Also, data is immutable but not persistent, i.e. there will be no requirement to "update" values of inner or outer nodes, turn back time or to merge two or more branches..

In effect I am growing n Stacks where each list head / leaf node represents the top of a Stack, and through recursion I can track back up the "graph paths", i.e. the set of list tails / branches possibly to the root node or just to an inner node.

PS: have no interest in flattening g said multi-level linked list. Just want to treat them is a set of discrete & navigable (towards root) in effect Stacks.