News for hackers. Stuff that matters.
Re:JavaScript Algorithms and Data Structures (2018) by wffurr on Friday October 22, 2021 @10:36AM (#28957750)
Only the usual reasons to use a linked list. E.g. if you want to store stable references to cells in the linked list as in a linked hash map.
Re:JavaScript Algorithms and Data Structures (2018) by filoeleven on Friday October 22, 2021 @09:33PM (#28964828)
Are there practical reasons for using a linked list in JS? This is an honest question. I’ve taken immutability to heart, so storing a stable yet presumably mutable reference to a cell seems like a bad idea to me. (If it’s immutable, you can keep and use the cell’s value instead of caring that it came from a list.)
Re:JavaScript Algorithms and Data Structures (2018) by oweiler on Friday October 22, 2021 @02:40PM (#28960888)
That would be JavaScripts native Map, no?
Re:JavaScript Algorithms and Data Structures (2018) by wffurr on Friday October 22, 2021 @03:10PM (#28961326)
TIL ES6 Map is guaranteed to iterate in insertion order. That always made me crazy in C++ too; the structure that I usually actually want is std::unordered_map not std::map.

There are other algorithms and use cases for a stable iteration into an ordered sequence, but I can’t think of any off-hand. It is true that it’s rare to prefer a linked list on modern CPU architecture.