News for hackers. Stuff that matters.
Re:In Defense of Linked Lists by kelnos on Friday November 04, 2022 @07:18PM (#33475455)
Isn't that the opposite, though? If you store the next/prev pointers in the data structure itself, you can't use the same object in multiple collections.

If you have a standalone linked list data structure, then you can, as long as you have a good means of tracking the lifetime of the data itself.

Re:In Defense of Linked Lists by nirs on Friday November 04, 2022 @08:33PM (#33476237)
Typically you keep a list entry in the struct: https://man7.org/linux/man-pages/man3/stailq.3.html#EXAMPLES

The same list entry can be moved between several lists using the same type.

If the struct need to be in multiple lists in the same time you can keep multiple list entries in the same struct: https://github.com/freebsd/freebsd-src/blob/69413598d2660054...