3 ms·
For those reading, you need to read comments by "thestinger" very carefully. A lot of people respond as if he made the following two claims: 1) Recursive data
by aidenn0 13y ago
For those reading, you need to read comments by "thestinger" very carefully.
A lot of people respond as if he made the following two claims:
1) Recursive data structures are rare
2) Singly linked lists are useless
When in fact he made these two claims:
1) definitions of recursive data structures are not prevalent in code
2) unshared singly-linked lists are not useful
#1 is true since you define a recursive data structure only once, no matter how often you use it.
#2 is slightly less obvious. One of the big advantages of a singly linked-list over other structures is that you can share tails with multiple lists. With unique ownership that advantage goes away. (There is still the use-case of loaning out tails, but that is a fairly weak argument).
Another advantage of a singly-linked list is ease of implementation; that is negated when your standard library provides dynamic arrays and stacks already baked in.